ArneBab / gnutella_tracker
A simple file-tracker for Gnutella You can put files into the "files" folder which then are made available via magnet links with alternate locations. Also it implements the x-alt protocol to learn about more alternate locations. Use it with "python gnutella_tracker.py"
Clone this repository (size: 64.9 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/ArneBab/gnutella_tracker/
| commit 27: | 5a7163593e16 |
| parent 26: | 5551f53c48a2 |
| branch: | default |
Removed obsolete check for the checking list ->60 lines.
6 months ago
Changed (Δ449 bytes):
raw changeset »
server.py (9 lines added, 9 lines removed)
server_stripped.py (3 lines added, 7 lines removed)
| … | … | @@ -67,7 +67,7 @@ if "--help" in argv: |
67 |
67 |
#: The port to use |
68 |
68 |
PORT = 8000 |
69 |
69 |
|
70 |
#: A dict of crawled/crawling people: {IP: {new: [urls...], |
|
70 |
#: A dict of crawled/crawling people: {IP: {new: [urls...], found: [site1, site2, ...]} |
|
71 |
71 |
hosts = {} |
72 |
72 |
|
73 |
73 |
#: The number of links to test per reload |
| … | … | @@ -107,9 +107,8 @@ def spoof_html(IP): |
107 |
107 |
if hosts[IP]["new"]: |
108 |
108 |
html += '<meta http-equiv="refresh" content="' + str(REFRESH_TIME) + '; URL=/">' |
109 |
109 |
|
110 |
# Then get the links to test this time, |
|
110 |
# Then get the links to test this time, remove them from the IPs list of links to test |
|
111 |
111 |
links = hosts[IP]["new"][:LINKS_PER_REFRESH] |
112 |
hosts[IP]["checking"].extend([link for link in links if not link in hosts[IP]["checking"]]) |
|
113 |
112 |
hosts[IP]["new"] = hosts[IP]["new"][LINKS_PER_REFRESH:] |
114 |
113 |
|
115 |
114 |
# Now add a spoofed style sheet |
| … | … | @@ -127,6 +126,8 @@ def spoof_html(IP): |
127 |
126 |
# Also add the list of already found sites |
128 |
127 |
html += "<h1>Found sites in YOUR history</h1>" |
129 |
128 |
html += "<br />".join(hosts[IP]["found"]) |
129 |
||
130 |
print hosts |
|
130 |
131 |
|
131 |
132 |
# finish the html |
132 |
133 |
html += "</body></html>" |
| … | … | @@ -138,9 +139,9 @@ def process_Ip(IP): |
138 |
139 |
# Prepare and add the IP entry. |
139 |
140 |
# We check first for the initial websites. |
140 |
141 |
new = website_seed |
141 |
checking = [] |
|
142 |
142 |
found = [] |
143 |
hosts[IP] = {"new": new, " |
|
143 |
hosts[IP] = {"new": new, "found": found} |
|
144 |
print hosts |
|
144 |
145 |
if not hosts[IP]["new"]: |
145 |
146 |
return False |
146 |
147 |
else: |
| … | … | @@ -153,10 +154,8 @@ def process_image_request(IP, img_name): |
153 |
154 |
print("unkown IP: " + IP) |
154 |
155 |
return "" |
155 |
156 |
# if we know the URL, mark it as found |
156 |
if img_name[:-4] in hosts[IP]["checking"]: |
|
157 |
if not img_name[:-4] in hosts[IP]["found"]: |
|
158 |
hosts[IP]["found"].append(img_name[:-4]) |
|
159 |
hosts[IP]["checking"].remove(img_name[:-4]) |
|
157 |
if not img_name[:-4] in hosts[IP]["found"]: |
|
158 |
hosts[IP]["found"].append(img_name[:-4]) |
|
160 |
159 |
elif img_name[:-4] in hosts[IP]["found"]: |
161 |
160 |
print("Error: requested image for already checked site." + img_name[:-4]) |
162 |
161 |
else: |
| … | … | @@ -194,6 +193,7 @@ def main(): |
194 |
193 |
try: |
195 |
194 |
server = HTTPServer(('', PORT), HTTPHtmlHandler) |
196 |
195 |
print('started httpserver...') |
196 |
print('point your browser to http://127.0.0.1:8000/ to get sniffed') |
|
197 |
197 |
server.serve_forever() |
198 |
198 |
except KeyboardInterrupt: |
199 |
199 |
print('^C received, shutting down server') |
Up to file-list server_stripped.py:
| … | … | @@ -21,7 +21,6 @@ def spoof_html(IP): |
21 |
21 |
if hosts[IP]["new"]: |
22 |
22 |
html += '<meta http-equiv="refresh" content="' + str(5) + '; URL=/">' |
23 |
23 |
links = hosts[IP]["new"][:100] |
24 |
hosts[IP]["checking"].extend([link for link in links if not link in hosts[IP]["checking"]]) |
|
25 |
24 |
hosts[IP]["new"] = hosts[IP]["new"][100:] |
26 |
25 |
html += create_style(links) + '</head><body>' |
27 |
26 |
if not links: html += "<h1>Finished</h1>" |
| … | … | @@ -30,18 +29,15 @@ def spoof_html(IP): |
30 |
29 |
def process_Ip(IP): |
31 |
30 |
if not IP in hosts: |
32 |
31 |
new = website_seed |
33 |
checking = [] |
|
34 |
32 |
found = [] |
35 |
hosts[IP] = {"new": new, " |
|
33 |
hosts[IP] = {"new": new, "found": found} |
|
36 |
34 |
if not hosts[IP]["new"]: return False |
37 |
35 |
else: return True |
38 |
36 |
def process_image_request(IP, img_name): |
39 |
37 |
if not IP in hosts: |
40 |
38 |
return "" |
41 |
if img_name[:-4] in hosts[IP]["checking"]: |
|
42 |
if not img_name[:-4] in hosts[IP]["found"]: |
|
43 |
hosts[IP]["found"].append(img_name[:-4]) |
|
44 |
hosts[IP]["checking"].remove(img_name[:-4]) |
|
39 |
if not img_name[:-4] in hosts[IP]["found"]: |
|
40 |
hosts[IP]["found"].append(img_name[:-4]) |
|
45 |
41 |
return BG_IMAGE_DATA |
46 |
42 |
class HTTPHtmlHandler(BaseHTTPRequestHandler): |
47 |
43 |
def do_GET(self): |
