Results 1 to 2 of 2

Thread: Python - Kayses Tutorials Part two - Automating Dailys

  1. #1
    Banned
    Join Date
    Jun 2012
    Gender
    Location
    90 90
    Age
    31
    Posts
    1,714
    Thanks
    876
    Thanked 2,877 Times in 1,139 Posts


    Downloads
    44
    Uploads
    1
    Mentioned
    562 Post(s)
    Time Online
    118 d 6 h 45 m
    Avg. Time Online
    1 h 30 m
    Rep Power
    0
    Gamer IDs

    Gamertag: DarkByt3 PSN ID: raredaredevil

    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 http://www.neopets.com/water/fishing.phtml 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:



    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 http://www.neopets.com/water/fishing.phtml with the post data go_fish=1.

    2.Do the above with the refferal url set to http://www.neopets.com/water/fishing.phtml .

    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.




    postdata = {"go_fish" : "1"}


    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 http://www.neopets.com/desert/sc/kiosk.phtml. 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 http://www.neopets.com/desert/sc/kiosk.phtml.

    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:



    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 http://www.neopets.com/desert/sc/kiosk.phtml 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.


    I then searched for “_ref_ck” in notepad and landed here



    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:




    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!


    First we find the position of “_ref_ck” in the html source.


    here we make sure the above code was found in the code , before continuing just to prevent errors.





    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!

    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


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




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


    Lets now change

    to store to a varible for later by changing it to this:




    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:



    So add the following code to your project:



    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 http://www.neopets.com/desert/sc/kiosk.phtml. 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 10:37 AM.

  2. The Following 14 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),hectorvazc (06-30-2014),I_royalty_I (01-25-2014),Infamous Joe (01-25-2014),joker (03-28-2016),lombardis (04-06-2014),Mrfugix (01-25-2014),mt5o5bd (02-05-2014),purekilla (01-27-2014),Tablo (08-03-2014),User5931 (06-03-2015)

  3. #2
    Banned
    Join Date
    Jun 2012
    Gender
    Location
    90 90
    Age
    31
    Posts
    1,714
    Thanks
    876
    Thanked 2,877 Times in 1,139 Posts


    Downloads
    44
    Uploads
    1
    Mentioned
    562 Post(s)
    Time Online
    118 d 6 h 45 m
    Avg. Time Online
    1 h 30 m
    Rep Power
    0
    Gamer IDs

    Gamertag: DarkByt3 PSN ID: raredaredevil
    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-04-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
  •