Help sending data over a socket

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WhiteRider
    New Member
    • Sep 2007
    • 37

    #1

    Help sending data over a socket

    I have some basic knowledge of socket programming in Python. Up to now all I have been able to do when establishing a socket is sending a string to a client, what I would like to know is what else can be sent? For example could a program be tunnelled through from the host to the client - like the way netcat allows programs to be executed after a connection is established?

    Here is code that only sends a string:

    Code:
    #!/usr/bin/python
    import socket, sys
    
    if len(sys.argv) < 3:
        print 'Usage: %s [IP] [port]' % sys.argv[0]
        sys.exit(1)
    
    ip = sys.argv[1]
    port = int(sys.argv[2])
    
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    
    
    sock.bind((ip, port))
    sock.listen(1)
    print "Waiting for someone."
    
    request, client = sock.accept()
    print "Received connection from", client
    request.send('Some boring text..\n') #<-- can a program be sent instead of this?
    request.shutdown(2) 
    print "Socket closed."
    sock.close()
  • WhiteRider
    New Member
    • Sep 2007
    • 37

    #2
    Does no-one have any knowledge on Python Socket programming that they could share with me?

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      Originally posted by WhiteRider
      Does no-one have any knowledge on Python Socket programming that they could share with me?
      The best indication of the amount of action regarding this issue is the first hit on Google for python socket tutorial:Socket Programming HOWTO (1998). But I'll keep digging.

      Comment

      • WhiteRider
        New Member
        • Sep 2007
        • 37

        #4
        Originally posted by bartonc
        The best indication of the amount of action regarding this issue is the first hit on Google for python socket tutorial:Socket Programming HOWTO (1998). But I'll keep digging.
        I've read that HOWTO. Problem is, is that it only tells you how to set-up a socket. I'm comfortable setting up TCP or UDP sockets I just want to branch out and do others things such as send files or as I mentioned in the first post, tunnel things, like a reverse shell or something interesting like that.

        Comment

        Working...