Jump to content

Http POST, omegle, and not working


Recommended Posts

I am trying to write a UDF to connect directly to the omegle protocall. The way omegle works is that

1 - It sends a request to http://www.omegle.com/start, this responds with a chat ID, say "FiidPi".

2 - It takes "FiidPi" and plugs it into http://www.omegle.com/events?id=<IDHERE> and the return should be in the format

There is more info on omegle's protocall here

The first thing I wanted to try was using INetGet(), which worked for getting the ChatID but not the Message.

$hChat = omegle_open()
ConsoleWrite($hChat&@CRLF)
$msg = omegle_get($hChat)
ConsoleWrite($msg&@CRLF)

Func omegle_open()
    Return iNetGetSource("http://www.omegle.com/start")
EndFunc

Func omegle_settypeing($hChat, $t = 1)
    if $t = 1 Then
        InetRead("http://omegle.com/typing?id="&$hChat)
    EndIf
EndFunc

Func omegle_send($hChat, $msg)
    InetRead("http://omegle.com/send?msg=" & $msg & "&id=" & $hchat)
EndFunc

Func omegle_get($hChat)
    $return = iNetGetSource("http://www.omegle.com/events?id="&$hChat)
    If $return = "null" then Return $return ;this means something went wrong
    Return StringTrimRight(StringTrimLeft($return,1),1)
EndFunc

Func iNetGetSource($url)
    Local $temp = Random(10000,99999,1)&".html"
    InetGet($url,$temp)
    $return = FileRead($temp)
    FileDelete($temp)
    Return $return
EndFunc

This didn't work, so I tried doing it useing the POST methiod. The UDF I used is found This one also gets the ChatID but also fails at step 2, getting the messages.

#include "http.au3"
#include <array.au3>
; _HTTPConnect - Connects to a webserver
; _HTTPGet - Submits a GET request to a webserver
; _HTTPPost - Submits a POST request to a webserver
; _HTTPRead - Reads the response from a webserver

$hPort = Omegle_connect()
$hChat = Omegle_chat_start()
;~ consolewrite($hChat&@CRLF)
sleep(100)
;~ Omegle_chat_get($hChat)
ConsoleWrite(Omegle_chat_get($hChat)&@CRLF)

Func Omegle_connect()
    Return _HTTPConnect("www.omegle.com")
EndFunc

Func Omegle_chat_start()
    _HTTPPost("www.omegle.com","/start")
    Return _HTTPRead()
EndFunc

Func Omegle_chat_get($ID)
    consolewrite($ID&@CRLF)
    consolewrite($hPort&@CRLF)
    _HTTPPost("www.omegle.com","/events?id="&$ID)
;~  $a = _HTTPRead($hPort,1)
;~  _ArrayDisplay($a)
    Return _HTTPRead()
EndFunc

If you are wondering why I would want to do such a thing, Then here is an explanation. The main idea is to have a client that will connect to 4 omegle chats at once, ask everyone for a name, and then connect all 4 chats by prefixing what everyone says with the name they gave and sending it to the other 3 chatters. I have already messed with the code for handling the 4 clients and sending them to each other, but I cannot get the messages from omegle.

Any help would be greatly appreciated.

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Update

I tried a different method, using the IE functions. Getting the text for the chat was easy, as the code shows: Open it, click "Text", talk for a bit, and hit Numpad 0.

HotKeySet("{numpad0}","FOO")
OnAutoItExitRegister("cleanup")
#include <IE.AU3>
#include <ARRAY.AU3>

Global $hChat = _IECreate("http://bajor.omegle.com/")

while 1
    sleep(1234)
WEnd

Func foo()
    $a = StringRegExp(_IEBodyReadHTML($hChat),"class=msgsource>.*?</DIV></DIV>",3)
    for $i = 0 to UBound($a)-1
        $a[$i] = StringReplace(StringReplace(StringReplace($a[$i],"class=msgsource>",""),"</DIV>",""),"</SPAN>","")
    Next
    _ArrayDisplay($a)
EndFunc

Func cleanup()
    _IEQuit($hChat)
EndFunc)

This works quite well. The problem comes with replying, as I cannot fogure out this part. I know how to submit data on forms, but not with a page like this. the code for this section of the page is as follows:

<td class="chatmsgcell">
    <div class="chatmsgwrapper">
        <textarea class="chatmsg" cols="80" rows="3"></textarea>
    </div>
</td>

How do I enter text and send it as I would by just typing it using IE functions? I want to avoid using send(). I couldn't find a ID or Name, and there appears to be no Value to set. Can anyone out there help?

EDIT: better example code

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...