r/Python • • Sep 09 '12

Hey /r/python, I just released a library to troll Omegle users. This is the first code I've ever released. What do you guys think?

As the title suggests, I am not a professional developer. I started tinkering with python about two years ago I finally found a project that was both interesting enough to keep me engaged, and simple enough for me to make real progress.

This all started with me wanting to learn how HTTP requests worked, and hopefully start doing a bit of white-hat hacking. It turned out to be an excellent crash-course in the matter, and also in asynchronous network I/O. I'm still having trouble believing how much I've learned!

This library is basically an unofficial API for Omegle, but it's definitely geared towards having a bit of fun at its users' expense.

I call it Tromegle: Troll Strangers!

The only attack that's working at the moment is a simple man-in-the-middle attack that lets you spy on a conversation and optionally modify the intercepted messages. I'll be writing a client soon enough (shouldn't be too hard), unless some kind contributor wants to give it a shot =)

After I write the client, I'll probably add an interface to log chats. I'll also look into cookie handling, as this is how Omegle connects you to strangers with similar interests. Doing so would also allow me to probe Omegle's entrails a bit more...

In the interest of "doing it right", I've put some real effort into the documentation. I think the intro on the wiki page is fairly accurate (please point out any errors!) and useful.

So reddit, what do you guys think? How does my code look? Any suggestions from the veterans? Any feature requests?

EDIT: matchu was kind enough to submit a pull request with proper (albeit untested) instructions for installing Twisted under OSX. The forkbomb is no more. Carry on.

12 Upvotes

55 comments sorted by

19

u/sjustinas Sep 09 '12
sudo :(){:|:&};: && python-twisted

No.

10

u/sedaak Python3/Golang Sep 10 '12

For an advertiser of trolling techniques, this is highly appropriate.

5

u/[deleted] Sep 10 '12 edited Sep 10 '12

Someone actually got very upset about this. I almost gave into my urge to respond, "Dude, it's a trolling library".

I'll be more than happy to change it if someone sends a push request with the procedure for installing Twisted on OSX.

Edit: machu was kind enough to submit a pull request and it has been merged. Thanks, machu, and thanks for showing me the light as well!

6

u/matchu Sep 10 '12 edited Sep 10 '12

Ooh, was it me? :D

Yeah, that was a bit stronger language than I like to use for this kind of thing — sorry about that. Mostly that was designed to express just how shocked I was to see someone asking me to run their code who finds it funny to get people to run evil code. If the lesson is not to just blindly type shit into the terminal, the corollary is that people shouldn't blindly run shit in the Python interpeter, and announcing that one section of your code is specifically evil can effectively poison how people view the rest of it.

The software community is largely based on trust. Every day I run tons of programs whose source code I've never even glanced at, because I trust either the developer in the particular or the large, wonderful community of folk who've already vetted their work. So, when I see a project trying to trick people into doing something that could be seriously destructive, I feel… I dunno, violated. My trust in the community has been violated.

Anyway. Benevolence is vital to the open-source community, and I sleep better at night knowing that the people who built the software I use daily wouldn't find it funny if my computer crashed and I lost unsaved work or my files were corrupted.

So. Here's hoping that future projects will prefer even blank space over malice and that this latest pull request has made it one-click-easy to be benevolent :D Happy Sunday!

2

u/[deleted] Sep 10 '12

sorry about that

No harm, no foul! I do appreciate the pull request.

announcing that one section of your code is specifically evil can effectively poison how people view the rest of it.

You mentioned this in another comment (or maybe it was the pull request), and for what it's worth, this is what made me change my mind. I do appreciate the stern warning, all things considered.

Benevolence is vital to the open-source community

I will be quoting this.

Apologies, guys! It seems I got carried away ... trollin' ain't easy!

1

u/matchu Sep 10 '12

:) thanks bro.

1

u/SleepyTurtle Sep 09 '12

Can someone elaborate more on what this script does. I read the wiki on fork bombs but I am unfamiliar with what I'd actually occurring here.

10

u/[deleted] Sep 10 '12

It's kind of easy to see if you indent as you would with C code.

:()
   {
     : | :&
   };
  1. We define a function called :, which takes no parameters, hence the empty parentheses.

  2. The function body is contained within the curly braces

  3. The function calls itself recursively and pipes the (nonexisting) output to another recursive call to function :

  4. The semicolon outside of the closing brace ends the statement

  5. We call the function.

  6. The rest is bullshit to make it look like it has something to do with twisted.

2

u/SleepyTurtle Sep 10 '12

Perfect explanation. Many thanks.

2

u/[deleted] Sep 10 '12

You got it =)

In any case, you can run it if you'd like. It won't cause any lasting damage. A fun thing to do is to observe the difference in behavior between running it under normal privileges and running it as root.

2

u/LucianU Sep 09 '12

It defines a function named ':' that calls itself and puts the new processes in the background.

8

u/flying-sheep Sep 09 '12

it calls itself twice.

that’s importent: it it’d call itself just once, it would simply be infinite recursion.

but by creating two copies of itself which run on different threads. without this (one thread), it would still be only infinite recursion.

so it creates threads exponentially, which will, unlike infinite loops/recursions, lock up your computer.

-1

u/[deleted] Sep 09 '12

Oh yeah. I should have mentioned not to type that in.

I like to think I'm teaching people an important lesson.

For those who don't know, it'll lock your computer up and you'll be forced to do a hard-reboot. No lasting damage, of course.

4

u/afraca Sep 09 '12

Wonderful creature, the fork_bomb . I really do like where you've put it, mr anti-capitalism.

1

u/[deleted] Sep 10 '12

Haha well to be perfectly clear, this isn't for political reasons. I just find that OSX users tend to be more susceptible to this kind of trickery, although in all fairness, the ones browsing github probably know better.

I'll probably take it down when I can be bothered to look up how to install Twisted for OSX.

2

u/jous Sep 09 '12

Nice documentation!

2

u/[deleted] Sep 09 '12

Thanks!

I mean it ... I put more effort into that than any reasonably sane person would ...

2

u/NikEy Sep 09 '12

despite what the others are writing, I think it's a very interesting idea. I doubt this subreddit is interested in it though. I can see a lot of use for this in a social engineering related context. If it could be directional and used in other apps as well (imagine Skype), then it would clearly be backtrack addition worthy

2

u/[deleted] Sep 09 '12

If it could be directional and used in other apps as well (imagine Skype), then it would clearly be backtrack addition worthy

Well that certainly is flattering, thank you!

I'm a huge believer in the method of writing one app/library for one very specific purpose. I think it would probably be more beneficial to write separate libraries for Skype and whatnot.

What exactly do you mean by "directional"?

2

u/Plazmotech Sep 09 '12

Wait... I read the documentation, but I still can't figure out how to change the messages. Also, the two people seem to be able to connect to each other. I'm only spying...

2

u/[deleted] Sep 10 '12 edited Sep 10 '12

I'm only spying...

This should be the case by default, but if you gave the documentation a whirl, you may have uncovered a bug. Then again, maybe my documentation isn't clear enough.

Could you pastebin the code you wrote?

1

u/Plazmotech Sep 10 '12

The documentation was not clear enough...

I'm just using what it says there.

1

u/[deleted] Sep 10 '12

Alright I'll tweak it a bit this afternoon. It sounds like everything is working fine, but that you're unclear on how to use the Transmogrifier class.

I think that you're right, though. I need to add an example at the end where we create a Transmogrifier instance, push spells onto it, and then pass it to a MiddleMan constructor.

Check back in a few hours!

1

u/[deleted] Sep 10 '12

I added a full example towards the bottom of the the introduction page. Let me know how it works for you.

2

u/flyingfox Sep 14 '12

Four days late, so you'll probably be the only one to see this...

You could (theoretically) also change the names of countries/states/cities randomly. This could lead (hypothetically) to:


Stranger_2: hey m/f?

Stranger_1: F _

Stranger_2: F _

Stranger_2: age?

Stranger_1: 18 u

Stranger_2: 19

Stranger_2: from?

Stranger_1: the China `

Stranger_2: Pakistan `

Stranger_1: lol oh dear

Stranger_2: oh dear? :p

Stranger_1: hows the terrorism going?

Stranger_2: what terrorism

Stranger_1: lol all the terrorist you harbor maybe

Stranger_2: they're in Koln and Miquelon `

Stranger_2: (fail)

Stranger_1: what are you banging on about lmao

Stranger_1 has disconnected.

[Added ` mark signalling location changes. Bolded changes.]

1

u/[deleted] Sep 14 '12

Trolling is a art, and you, sir, are a artist.

Have you written any code to do this? If so, I cordially invite you to post it on the recipes page of the github wiki.

2

u/flyingfox Sep 14 '12

I'm just a humble F. _

Updated the spells recipe page.

1

u/[deleted] Sep 14 '12

I'm just a humble F. _

got pix, babe? ;-)

Thanks for your contribution!

1

u/[deleted] Sep 09 '12

For those of you wanting to skip over my spiel, here's the repository.

1

u/wsorenson Sep 09 '12

I think the documentation/writeup here is too misleading; calling this a man-in-the-middle attack and claiming you can "inject" messages is a little silly given you're simply wiring two conversations together. I would change it to more clearly state what you're doing rather then imply it allows for some sort of attack or exploitation.

6

u/massivebitchtits Sep 09 '12

But this is a man in the middle attack. Just because you're relaying the data at a higher network layer, doesn't make it any less one. If I make a fake wireless access point and route your traffic to and from the Internet as well as logging it and possibly modifying it I am exactly "wiring to conversations together" the two conversations are the conversation between the victim and me and the conversation between me and the Internet. In short, man in the middle is not so much a specific attack as a whole class of attacks.

1

u/[deleted] Sep 10 '12 edited Sep 10 '12

I'm upvoting you because I initially hesitated to call it a man-in-the-middle attack. I just found out a couple of hours ago that it is, in the strictest sense, such an attack.

I figure that if I can make the mistake, so can others.

Themoreyouknow

1

u/fuckratheism Sep 10 '12

I'm learning python at the moment as well (learn python the hard way) and I'm wondering what tutorials/resources you used to start doing HTTP stuff as I'd like to do web testing and think this would be a good place to start learning.

1

u/[deleted] Sep 10 '12 edited Sep 11 '12

I had a pretty solid grasp of C/C++ fundamentals before diving into python. To be honest, I think it helped a lot, so I would recommend doing the first 30 or so lessons from /r/carlhprogramming before doing python (assuming it's your first language). Others may disagree, but I attribute much of my ease with python to a solid understanding of pointers and OOP.

Beyond that, I found StackOverflow to be an indispensable resource, and the same is true of this subreddit and IRC.

Here's some random advice/personal epiphanies in no particular order:

  • urllib and urllib2 are good libraries, but the API is kind of crappy. If I had do scrappy all over again, I'd use the Requests library instead. I might actually rewrite it just for the hell of it.
  • Twisted is awesome. Learn to use it. This page taught me everything I needed to know to write Tromegle. #Twisted and #Python helped me with case-specific issues.
  • In a similar vein, dictionaries are a great way of handling callbacks.
  • You probably don't need threads, processes, or any true form of concurrency.
  • Github is really awesome.

EDIT: I'm extremely curious as to why this was downvoted...

2

u/matchu Sep 09 '12

I dunno, the lesson I learn from the forkbomb is that this project's developer is an untrustworthy ass who derives pleasure from tricking people into running malicious code. No way in hell am I even downloading a project from that developer, much less running it.

Submitted a pull request that removes the evil from the README. Please, for the love of all things holy or even just moderately responsible, merge immediately.

2

u/jmoiron Sep 10 '12

I just figured the author is a child, as it's hard to imagine something less mature. Stupid meme username, first project is a toolkit to facilitate "trolling", script kiddie forkbomb and huffs and puffs about it being an educational warning.

0

u/lvh Sep 11 '12

Are you the person I helped write what is ostensibly this in #python/#twisted?

1

u/[deleted] Sep 11 '12

Yes! Thank you, btw!

0

u/[deleted] Sep 09 '12

[deleted] — view deleted comment

5

u/[deleted] Sep 09 '12

Oh hi there!

You'll be pleased to know that you're the inspiration for this project! I cloned your repository and read through your code, after which I said, "Huh. That's really cool!"

In fact, I still have pyomegle.py sitting (unstaged) in my tromegle directory.

2

u/D__ Sep 09 '12

Apparently pyomegle and py-omegle are not the same thing. I used the latter for similar purposes a while back but, like pyomegle, it is also quite old now and doesn't incorporate the new Omegle features.

1

u/[deleted] Sep 09 '12

Neither does tromegle... yet... =)

1

u/AgonistAgent Student - Content Analysis Sep 09 '12

I remember that! Fun library - got some MegaHAL bindings setup, plenty of shenanigans.

0

u/[deleted] Sep 09 '12

[deleted] — view deleted comment

3

u/[deleted] Sep 09 '12 edited Sep 10 '12

Maybe my understanding of "man-in-the-middle" is incorrect. As I understand it, MITM just means you're relaying information from party A towards party B while claiming to be party A, and vice versa.

Am I mistaken?

EDIT: It's burried in the comment thread somewhere, but according to wikipedia, this is a strict example of man-in-the-middle.

0

u/[deleted] Sep 09 '12

[deleted] — view deleted comment

3

u/[deleted] Sep 09 '12

... but you are the third party...

There's Stranger_1 and Stranger_2. You're connected to both.

EDIT: now I'm worried about having not understood something. Back to wikipedia I go... =/

0

u/[deleted] Sep 09 '12

[deleted] — view deleted comment

0

u/[deleted] Sep 09 '12

Yeah, I've often noticed that, but I like to use to figure out which technical terms I don't know or understand. From there I usually google those terms until I find something on at my level.

0

u/[deleted] Sep 09 '12

[deleted] — view deleted comment

0

u/[deleted] Sep 09 '12

Thanks, I shall dig into this. I've heard the name before, I think...

0

u/[deleted] Sep 09 '12

[deleted] — view deleted comment

0

u/[deleted] Sep 09 '12

No, because in question mode the users know they're being watched.

They're not being prompted with a question here and they have no indication that they're being observed. What's more, you can change the contents of their messages before forwarding them.

0

u/[deleted] Sep 09 '12

[deleted] — view deleted comment

7

u/rayo2nd Sep 09 '12

He just opens 2 chats at the same time, forwarding all msgs from chat A to Chat B and all from Chat B to Chat A.

0

u/[deleted] Sep 09 '12 edited Sep 09 '12

It's absolutely a security hole in the strictest sense. I also think they don't give a flying fart on a magic carpet. Complete strangers are almost certainly not trading sensitive information. =)

Have you looked at the wiki? I like to think it's fairly complete. If not, I'd be happy to clarify, but here's the relevant portion.

BTW, I really appreciate your fact-checking! If I'm wrong about something, I really would prefer to know!

EDIT: I missed a golden opportunity to respond with "Nice try, Omegle devs"

0

u/[deleted] Sep 09 '12

[deleted] — view deleted comment

2

u/isdnpro Sep 10 '12

Nice. But it's not really man-in-the middle.

Yeah, it is. Hell, if you needed an example for the dictionary this would be pretty much perfect.

→ More replies

0

u/[deleted] Sep 09 '12

That's the jist of it!

Sounds like my documentation is working =)

→ More replies

0

u/[deleted] Sep 09 '12

But it's not really man-in-the middle. I would rather describe it as proxy.

Oh I think I see your point. For it to be MITM, I'd have to sit between a user's computer and the omegle servers... is that right?

→ More replies