1

A part of my job is to register several new users on to a third party gaming site. I have written a script using ahk using curl, it opens the browser and loops in filling the registration form and submitting, however the website isn't happy with that as it times out sometimes or complains about logging in too frequently in a short timeframe.

I'm looking to redo the script without having to open the browser, and I'm not sure what to use, php with curl, JavaScript?

Anyone has any good suggestions and references? I need something light and quick. Any help is greatly appreciated.

EternalHour
  • 8,308
  • 6
  • 38
  • 57
Sam
  • 73
  • 1
  • 9

1 Answers1

1

I recently made a post about the WinHttpRequest COM and explained how to do logins with it: How to do logins using the WinHttpRequest COM?

If you reverse engineer your target site a bit you could change the provided code to send the data required for registration to the server.

It would probably look somewhat like this:

;Prepare our WinHttpRequest object
HttpObj := ComObjCreate("WinHttp.WinHttpRequest.5.1")
;HttpObj.SetProxy(2,"localhost:8888") ;Send data through Fiddler (for debugging)
HttpObj.SetTimeouts(6000,6000,6000,6000) ;Set timeouts to 6 seconds
;HttpObj.Option(6) := False ;disable location-header rediects

;Set our URLs
registrationURL := "http://yoursite/registerOrWhatever/"

;Set our registration data
username := "Samah"
email := "myEmail@foo.bar"
password := "mySecretPassword"
acceptTOS := 1
receiveNewsLetter := 0

registrationBody := "username=" username "&email=" email "&repeatEmail=" email "&password=" password "&repeatPassword=" password "&TOSagree=" acceptTOS "&weeklyNewsLetter=" receiveNewsLetter

HttpObj.Open("POST",registrationURL)
HttpObj.SetRequestHeader("Content-Type","application/x-www-form-urlencoded")
HttpObj.Send(registrationBody)

If (HttpObj.status == 200 && InStr(HttpObj.ResponseText,"You will shortly receive an email with an activation link."))
    MsgBox, User successfully registered.
Else
    MsgBox, The registration failed!
Community
  • 1
  • 1
Forivin
  • 14,780
  • 27
  • 106
  • 199
  • Forvin, TY. I used your code, and edited the page elements as you suggested, however I am getting the 404 response status. In your example link, logging into the ahk site, you have the site url and a login url, ;Set our URLs loginSiteURL := & loginURL := while here there is only the url for the log in form, maybe that is the problem? I managed to get the response body. The registration form submit goes into two different gaming servers. EDIT: I added the link in the form action attribute. I get the "User successfully registered" now, but when I check on the site, the user does not exist. – Sam Apr 12 '15 at 03:49
  • I found another link to register, however the form is in a javascript and hidden by default (Login shows, Register is the next tab) how can I fill that hidden form? using the IDs returned a successful result, but user is still not registering. – Sam Apr 12 '15 at 04:10
  • The trick is to not look at the form, but to look at what the html site is actually sending to the server. Download the program Fiddler and run it. On the right side of your window select the "Inspectors" tab and then select the "Webforms" tab that appears below that. On the very bottom left of the window click until it says "Capturing". Now open your browser and register a new user on your site. Go back to Fiddler and on the left side of the window, look for a request in the list that has a piece of pager with a green arrow on it as an icon. Click it and the post parameters will show up. – Forivin Apr 12 '15 at 07:43
  • Now you know, the url you need to send the request to and the post parameters you need to send in the request body. For Autohotkey.com for example, this: http://i.snag.gy/xqp3M.jpg translated into that: http://i.snag.gy/i1LkQ.jpg To see what these parameters would translate to in a raw http request as we have to create, click the "Raw" tab near the "WebForms" tab. – Forivin Apr 12 '15 at 07:52
  • Any idea about the second question? (Filling a hidden form) or even clicking its JavaScript link to make is visible. – Sam Apr 12 '15 at 15:52
  • This was an answer to that question. It's not a good idea to look at the forms, because an http request isn't neceseraly sent using the form per se. A lot of sites use javascript functions for that (xmlhttprequest, ajax, etc). And reverse enineering all that usually just takes too much time. It's much easier and safer to look at the http traffic, find the request and then just immitate it. If you'd provide the url for your target site, I'd take a look at it. – Forivin Apr 12 '15 at 17:32
  • Hi again Forivin. Thank you. I tried your instructions using Fiddler and still no success. I get the "User successfully registered", but when I check on the site, the user does not exist. Here's the target site. http://www.evony.com/evonyvc.html?vc – Sam Apr 12 '15 at 17:46
  • Yeah, that's a very complicated one. I wasn't able to replicate the whole registration process. It is possible, that the server expects you to request all the flash files before the registration actually finishes. (When I disabled flash in my browser the registration failed too). Well, this is what I ended up with: http://pastebin.com/5FaRdGQY I already spent an hour on testing and trying things out, without success.. Maybe you can finish it. – Forivin Apr 12 '15 at 20:58
  • thank you very much Forivin for your help. I will try what you suggested. http://user.evony.com/index.do?PageModule=UsersGetAccountByEmail is another way to register, without the flash files, I am just struggling to get to the Registration form (clicking Register) – Sam Apr 12 '15 at 21:25