forked from fengor/ctf-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exploit_template.py
50 lines (44 loc) · 1.38 KB
/
exploit_template.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
#! /usr/bin/env python
import socket
import os, sys
import urllib, urllib2
import re
import time
def submit(*args,**kwargs):
TEAMIP = '10.0.17.3'
TEAMID = 7
GAMESERVER = '10.0.3.3'
PORT = 31337
for flag in args:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((GAMESERVER, PORT))
msg = s.recv(1024)
print msg
s.send('7\n')
msg = s.recv(1024)
print msg
s.send(flag+'\n')
print s.recv(1024)
def http_request( url, values, method, cookies=None):
data = urllib.urlencode( values )
if method == 'GET':
url = url + '?' + data
req = urllib2.Request( url )
if method == 'POST':
req = urllib2.Request( url, data )
if cookies:
string = ''
for name, val in cookies.items():
string += '{}={}; '.format(name,val)
req.add_header('Cookie', string)
response = urllib2.urlopen( req, timeout=2 )
return response.read()
class Exploiter(object):
def run(self, host):
print 'Trying host', host
#Place exploit here
e = Exploiter()
while True:
start = e.run(sys.argv[1])
print 'sleeping...'
time.sleep(60)