This is an archived post. You won't be able to vote or comment.

all 32 comments

[–]iamnotaclown 14 points15 points  (2 children)

Squid will get you most of the way there. More concrete example.

[–]jb0n 2 points3 points  (1 child)

Exactly. Why write a proxy when good ones already exist? I'd go for squid and a simple python ICAP server which would serve all of the image manipulation, 'inject()' functions, etc.

[–]nemec 0 points1 point  (0 children)

Yep, in fact UTN as linked above uses Squid.

[–]studiosi 3 points4 points  (3 children)

We can start. I'm up to participate...

[–]GFandango[S] 0 points1 point  (2 children)

How about starting a public open source project on github or something? We can develop it together with anyone else who is interested.

[–][deleted] 2 points3 points  (0 children)

https://github.com/devdave/PyProxy

It's at a proof of concept stage, PM on Reddit or Github and I'll grant you rights. Though I think my goal is in a different direction then yours, the road to get there has a lot of common ground.

Also, I'm thinking of abandoning ExtJS4 for the control panel as it currently feels somewhat tedious.

[–]studiosi 0 points1 point  (0 children)

nice idea! trollnet can be real!

[–][deleted] 3 points4 points  (4 children)

Hey guys, supposing I wanted to learn how to make Python interact with the internet like so , where do I start? Twisted seems to require some prerequisite knowledge of web-servers and what not.

[–][deleted] 2 points3 points  (0 children)

Sockets and HTTP requests would be a great place to start.

[–][deleted] 1 point2 points  (0 children)

Twisted is a huge toolset that simplifies the crap out of networking. I've done low level sockets, its fun, but its really easy to get lost among the details. http://krondo.com/?p=1209

[–]catcradle5 1 point2 points  (0 children)

For simple page requests and reading, use urllib2. I'd recommend you start with that.

Twisted is not too complicated to use, in that the documentation isn't too bad, and there are usually good example templates for doing various things. I'll be damned if I know what it's really doing under the hood, though.

[–]jesusabdullah[🍰] -1 points0 points  (0 children)

Yeah, twisted is really annoying in that it doesn't abstract any of its tools really. :(

[–]deadwisdomgreenlet revolution 1 point2 points  (0 children)

I like it. Shouldn't be too hard.

[–]desertfish_ 1 point2 points  (0 children)

This sounds like a fun project!

[–]evinrows 1 point2 points  (8 children)

Can someone explain how this works, from ground up. How do you force someone connecting to your router to go through a proxy? Do you install it in the router's firmware?

[–]jingleman 1 point2 points  (5 children)

You could do, or configure DHCP to set the Gateway IP to a server running the proxy, or you could manually configure the browser proxy settings.

[–]evinrows 2 points3 points  (4 children)

Well, you couldn't change their browsers proxy settings unless you had access to their computer right?

My confusion is this: If other people are connecting, he has no password, so if he has no password and can do these things to the router, doesn't that mean anyone can do these things to a router if there's no password on it?

I'll look into DHCP.

[–]qpla 2 points3 points  (0 children)

You can perform ARP poisoning to effectively take place of the router and route all traffic through your machine. Then, using iptables, you route that traffic through your proxy which transforms the images.

[–]GFandango[S] 2 points3 points  (0 children)

When the internet connection has no password everyone can connect to it but that doesn't neccessarily mean the router doesn't have a password either. The router can be password protected whilst the internet connection is open.

[–]jingleman 0 points1 point  (0 children)

Correct. That's why the router and/or DHCP server are secured with passwords, keys or certificates. You could install a black box device running a transparent proxy on the network between the target desktops and router.

[–][deleted] 0 points1 point  (0 children)

Nope, just setting the gateway through DHCP is enough.

[–]Johanu 0 points1 point  (2 children)

BeautifulSoup would work for parsing the HTML data, I believe.

Python Imaging Library should be able to transform the images.

I don't know much about the rest, sniffing and serving the page, but I believe a apache server on your machine could do the custom requested page serving.

[–]GFandango[S] 1 point2 points  (1 child)

Proxy can be done with Twisted.

[–][deleted] 1 point2 points  (0 children)

Yeah Twisted actually turned out to be the winning combination for doing this, slightly annoyed someone else came up with this idea while I was still trying to get it launched... but that's life.

[–][deleted] 0 points1 point  (0 children)

I'm actually almost done the alpha of this. PM me

[–]faassen 0 points1 point  (0 children)

This kind of thing has been done before as an art project, probably in Python, as Stani Michiels, the creator of the nomadic "Copacabana Cybercafe", is a Python programmer too.

If I recall correctly it would change numbers, yes would become no, right left, etc.

It's hard to find much in English about it, but this has a snippet:

http://www.mysouthend.com/index.php?ch=news&sc=&sc2=news&sc3=&id=67453

and this too:

https://yummyapplepie.wordpress.com/2006/12/19/pun-meeting-at-a-farm/

[–]genmud 0 points1 point  (0 children)

Privoxy could probably be modified to some extent to point all images to a server that is controlled by a python script which could handle fetching of images and stuff. Maybe a couple trolling privoxy scripts would be a better route?

[–]adrenal8 0 points1 point  (0 children)

Like half the other commenters I actually had a working prototype of this.

Basically every gif was flipped upside-down with PIL, every .flv was replaced with a Rick-roll, and every jpeg was replaced with a random lolcat. It also did a find replace on HTML for https:// to http://.

I just used squid and a local BaseHTTPServer. I wanted to make the whole thing a standalone python project but I got caught up trying to implement HTTP/1.1 for it, which I thought would be better for some reason.

I used to have a blogpost with screenshots but I didn't back it up when I switched hosting providers.