Results 1 to 2 of 2

Thread: Python - Kayses Tutorials Part two - Automating Dailys

  1. #1

    Joined
    Jun 2012
    Posts
    1,699
    Thanks
    876
    Thanked
    2,881/1,142
    DL/UL
    44/1
    Mentioned
    562 times
    Time Online
    118d 6h 45m
    Avg. Time Online
    40m

    Python - Kayses Tutorials Part two - Automating Dailys

    Creating cheats for web based games for kayse



    Introduction

    Today we will automate some dailys we will learn a few different types of daily to automate. Some use different rules to others. We will also learn about string manipulation!


    Note:
    This post contains a attachment with the following files:
    Lesson 1 files - The files we start the code with
    Lesson 2 files - The finished code at the end of this lesson



    Step 0.1 – Firefox plugins
    Before we continue lets get the addon “tamper data” firefox and also change firefoxes view so the menu is visable , by going to view > Toolbars > Menu Bar. This just makes it easier to see our plugins. This plugin is used to show data for html forms. It tells us each item name and also each items value in a form. And also lets us know if its being executed with get or post. It makes life easier.




    Step 0.2 – Automating Under Water Fishing
    We are doing this game first because there are a few games similar to it. This game just contains a button that you hit and it submits a html form.

    To automate a game we must first understand how that game works. Open tamper data by going to tools > tamper data. Now load (you need an account to see links) and press Start Tamper in firefox when the page is completed loading. Press Reel in your line and tamper data will pop up. Untick the box that says continue tampering and press the tamper button. In the right window we see out post data as follows:

    PHP Code:
    go_fish 
    Also take note of the refferer url on the right hand side. This is the url we was sent from and neo uses it sometimes for security so we will make sure its set later. We now know how this game functions. To summarize we must do this


    1.load (you need an account to see links) with the post data go_fish=1.

    2.Do the above with the refferal url set to (you need an account to see links) .

    Now lets add the code to the end of our python script (remove the last 2 lines we added in the previous tutorial first that just made the html contents print neopets.com home page. We dont need that now.


    PHP Code:
    postdata = {"go_fish" "1"}
    html acc.post("http://www.neopets.com/water/fishing.phtml"postdata "http://www.neopets.com/water/fishing.phtml")
    print 
    html 
    postdata = {"go_fish" : "1"}
    PHP Code:
    Here we make a new dicT object and add our post data to it this is needed for the post function. 
    PHP Code:
    html acc.post("http://www.neopets.com/water/fishing.phtml"postdata "http://www.neopets.com/water/fishing.phtml"
    Here we set the varible html to the contents of acc.post (post data function) of the form page. We send 3 params , 1 is the url of the form, 2 is the postdata varible , 3 is the refferal url)

    finaly we print a output , like in tutorial one save this to a .htm file and view it. Our code worked and the daily executed! Easy right?! Well not all are that easy but we got one down at least.....



    Step 0.2 – Automating Scratch Cards


    We will be automating (you need an account to see links). All cards code is pretty much the same however. Now you may be thinking but wait this is just a button the same as fishing , this will be easy! However if you attach tamper data first and press start tamper you can see thats not true! Here buy is set to 1 just like fishing was set with go_fish however there is a second param called “_ref_ck”. This is a security step by neopets. The value of this is random and is taken from the buy pages html. So we now know to automate this game we must do the following:


    1.Goto (you need an account to see links).

    2.Extract the “_ref_ck”value from the html.

    3.Send post data of “buy=1&_ref_ck=RANDOMCODEHERE”


    This will buy our card. It is worth a note that the code we are going to use here can be used to extract EVERYTHING we need off neo. In any project.

    How much np does the user have on hand?

    Is X item name in shop?

    What result did out last attempt give?


    You can find all these with the code we will use today. It will become your best friend. This process is called string manipulation. It is also one of those things that is easier than it looks. Just get used to it first! Before we do anything lets comment out the code from yesterday to do this we add # to the beginning of each line. This will make python ignore our 2 lines of code but they will still be there for us later so our code from last section now looks like this:


    PHP Code:
    #postdata = {"go_fish" : "1"}
    #html = acc.post("http://www.neopets.com/water/fishing.phtml", postdata , "http://www.neopets.com/water/fishing.phtml") 
    We doe this because we don't want the code executing every time we run our script right now..


    My first step now is to print output of (you need an account to see links) then to paste it on notepad. We always do this rather than rely on firefoxes source code as firefox fixes code errors in html by itsself and can present a different html source to what our program gets causing conflicts and confusion we don't need.


    Here is the code we add to the end of the program to do that.
    PHP Code:
    html acc.get("http://www.neopets.com/desert/sc/kiosk.phtml")
    print 
    html 

    I then searched for “_ref_ck” in notepad and landed here
    PHP Code:
    <input type='hidden' name='buy' value='1'><input type='hidden' name='_ref_ck' value='178d636582a126202273bed207a75bd9'><input type='submit' value='Yes, I will have one please'></form></div><br><br><b>Scratching off your Scratchcard

    As we can see our ref_ck has a value of 178d636582a126202273bed207a75bd9 we need to extract this.


    To do this , we will use a “string.find(“string to find”)” function as our string is called html , we will therefore use html.find(“string to find”). This function returns -1 (integer) if the string is not found. If the string is found it returns the index number it was found at. That sounds complex its not , say we have this code:


    PHP Code:
    somestring = &#8220;this is a test string , python rocks dont u think?”
    print somestring.find(&#8220;test”) 
    This would print 10 , why? Because test is the 10th letter in the string (we count from 0). Html.find can also optionally take a second value that is a number. This number tells .find where to start searching from. We will use it later.




    The code:
    Now we know somethings about find we are going to use it to find the position of the random hash in our html output we do this like so:

    startpos = html.find("_ref_ck")
    if startpos > -1:
    start_trim = html.find("value='",startpos) + len("value='")
    end_trim = html.find("'",start_trim)
    print html[start_trim:end_trim]



    Whew theres a bit to get our head around here!

    PHP Code:
    startpos html.find("_ref_ck"
    First we find the position of “_ref_ck” in the html source.

    PHP Code:
    if startpos > -1
    here we make sure the above code was found in the code , before continuing just to prevent errors.



    PHP Code:
    start_trim html.find("value='",startpos) + len("value='"
    This time we use both paramaters on html.find First we find the position of "value='" in the html source and we start searching from the position of "_ref_ck". We then use len("value='"). This is because .find searches for the position the code was first found at but we want to skip the position immediately after that. Otherwise we would be extracting the words "value=". The len function just returns a integer of how long the string is. We add this to the result fron html.find.


    We now have the start position of our random string!
    PHP Code:
    end_trim html.find("'",start_trim
    The above code uses html.find to find the next comma after the position of starttrim (this the start position of out random hash). Because a comma is found 1 letter after our random hash we now have the position of the html immediately after the random hash too!




    Using this we can slice the html string like so
    PHP Code:
    html[Starnumber:Endnumber

    in the last line of code we do this...

    PHP Code:
    print html[start_trim:end_trim

    this should print the random hash knowing everything we know above.Run the script , it works...


    Lets now change
    PHP Code:
    print html[start_trim:end_trim
    to store to a varible for later by changing it to this:

    PHP Code:
    gamehash html[start_trim:end_trim

    gamehash now contains our random ref_ck value. Finally we have to throw all the above code into out new request the submits the information our form code was as follows:

    PHP Code:
    <input type='hidden' name='buy' value='1'><input type='hidden' name='_ref_ck' value='178d636582a126202273bed207a75bd9'><input type='submit' value='Yes, I will have one please'></form></div><br><br><b>Scratching off your Scratchcard</b><br><br><b>Oops!</bYou do not have any cards to scratch currently. If you have not purchased any scratchcards in the last 4 hoursthere is a button above that you can click to buy one.</div>

    <
    DIV align="center">

    <
    FORM action="/desert/sakhmet.phtml" method="get">

    <
    INPUT type="submit" value="Back to Sakhmet City">

    </
    FORM>

    </
    DIV
    So add the following code to your project:
    PHP Code:
    postdata = {"buy" "1" "_ref_ck" gamehash }
    html acc.post("http://www.neopets.com/desert/sc/kiosk.phtml"postdata "http://www.neopets.com/desert/sc/kiosk.phtml")
    print 
    html 

    This just throws all the data together and executes the new request. Then prints the html contents of the new page it also sets the refferal url (sending url) to (you need an account to see links). If you copy this to a file you will see you grabbed a scratch card. It worked.




    Now you have done this you should be able to simulate most daily games have a go at a few I know this is a lot to take in at first , but try a few out and it will get easier. The same concepts usually apply to most of the games. When you finish with some code , comment it out so its saved still but does not interupt your new codes .
    Attached Files Attached Files
    Last edited by DarkByte; 03-20-2014 at 09:37 AM.

  2. The Following 13 Users Say Thank You to DarkByte For This Useful Post:

    Arsura (01-27-2014),Ban (01-28-2014),Demetri (01-25-2014),Ghosts (08-02-2014),I_royalty_I (01-25-2014),joker (03-28-2016),lombardis (04-06-2014),Mrfugix (01-25-2014),mt5o5bd (02-05-2014),npm (06-29-2014),purekilla (01-27-2014),Tablo (08-03-2014),User5931 (06-03-2015)

  3. #2

    Joined
    Jun 2012
    Posts
    1,699
    Thanks
    876
    Thanked
    2,881/1,142
    DL/UL
    44/1
    Mentioned
    562 times
    Time Online
    118d 6h 45m
    Avg. Time Online
    40m
    Adding part 3 to youtube now(its a video) it teaches really the final things you need to know for your dailys bot, Delays ect...

    Ill make a video of how to create a money tree grabber next (probably tommorow)

  4. The Following User Says Thank You to DarkByte For This Useful Post:

    Ghosts (08-03-2014)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •