blob: f0e5ac67e3e17f2d8878d3c22b1e9513bfa9d620 (
plain) (
blame)
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
|
#!/usr/bin/env python3
import os
import sys
import subprocess
import time
import sploitconfig as config
import sploitutil as util
#infrastructure to run sploit
#if sploit is called with command line arguments,
#it will use them to call the target program with popen
#otherwise, sploit will use stdin/stdout
#you can use sploitpipe to run sploit with pipes spltin/spltout
#which can be used with the target program
#<spltin ./target &>spltout
#or from within gdb
#r <spltin &>spltout
def runsploit(sploit):
if config.use_popen:
print(sys.argv[1:])
p = subprocess.Popen(sys.argv[1:],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
stdin = p.stdout if config.use_popen else os.fdopen(0,"rb")
stdout = p.stdin if config.use_popen else os.fdopen(1,"wb")
if config.wait_for_gdb > 0:
time.sleep(config.wait_for_gdb)
#exec custom sploit
sploit(stdin,stdout)
#read anything else out and wait for termination
for line in stdin:
util.log(line)
if config.use_popen:
p.wait()
|