Captain09 Posted August 15, 2012 Share Posted August 15, 2012 hi, I'm new in the world of PHP so my question: is it possible to code a bot with PHP for a browsergame which can: - check if logged in else login into the game - search on a map for targets or get them from a file - attack this targets with an amount of troops - logout this php script should be run with a cronjob any idea how to code that? if need more informations just ask Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/ Share on other sites More sharing options...
xyph Posted August 15, 2012 Share Posted August 15, 2012 Yes, it's possible. You'll need to primarily use cURL. Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369480 Share on other sites More sharing options...
Captain09 Posted August 15, 2012 Author Share Posted August 15, 2012 is there a bit help for that? (I haven't used cURL yet) Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369482 Share on other sites More sharing options...
xyph Posted August 15, 2012 Share Posted August 15, 2012 There is, but asking others to help you cheat a game and run a bot that's GUARANTEED against their ToS isn't always going to get amazing reception. It's not exactly a beginner project, regardless. Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369484 Share on other sites More sharing options...
Mahngiel Posted August 15, 2012 Share Posted August 15, 2012 is there a bit help for that? (I haven't used cURL yet) give it a try and let us know how it works out. we'll be here if you have issues. Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369485 Share on other sites More sharing options...
tibberous Posted August 15, 2012 Share Posted August 15, 2012 Don't think your thinking of this exactly right. First, are you running this from your computer or a webserver? Because it shouldn't like you could run it on a windows PC and either use task scheduler or just a while(true) { sleep($x) } loop. Second, your going to open a new session with your PHP script -- you won't check to see if your logged in, you'll just log in. Essentially what you are doing is just automating the same get / post requests a browser would send. How complex that is depends on the game -- for example, are the units and terrain one image, or is the background an image and the units overlayed on top? Makes a big difference -- the first way you have to figure out pixel colors, the second you have to parse though some source. Regardless of the game, I'd consider this ambitious. Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369502 Share on other sites More sharing options...
Captain09 Posted August 15, 2012 Author Share Posted August 15, 2012 but asking others to help you cheat a game and run a bot that's GUARANTEED against their ToS isn't always going to get amazing reception. no, because this server is on my root Don't think your thinking of this exactly right. First, are you running this from your computer or a webserver? Because it shouldn't like you could run it on a windows PC and either use task scheduler or just a while(true) { sleep($x) } loop. webserver Second, your going to open a new session with your PHP script -- you won't check to see if your logged in, you'll just log in. Essentially what you are doing is just automating the same get / post requests a browser would send. How complex that is depends on the game -- for example, are the units and terrain one image, or is the background an image and the units overlayed on top? Makes a big difference -- the first way you have to figure out pixel colors, the second you have to parse though some source. Regardless of the game, I'd consider this ambitious. how do I see the post requests? There are some buttons which are no links but they send smth. like submit Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369564 Share on other sites More sharing options...
Mahngiel Posted August 15, 2012 Share Posted August 15, 2012 if this game is your own, you should have a working knowledge of the language you're using to write the game. if you don't know what you're doing in order to write this application, I suggest you start with an easier task. Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369609 Share on other sites More sharing options...
Captain09 Posted August 15, 2012 Author Share Posted August 15, 2012 the game is open source I didn't write it and this "little knowledge" isn't enough Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369624 Share on other sites More sharing options...
scootstah Posted August 15, 2012 Share Posted August 15, 2012 If this is a Flash game, I don't think it's doable with PHP. You would most likely have to manipulate the client for that, which PHP can't do. There are a number of ways to inspect POST data. I like the TamperData addon for Firefox, but you can use a number of other tools like Firebug or Live HTTP Headers (both are addons for Firefox). Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369627 Share on other sites More sharing options...
MMDE Posted August 15, 2012 Share Posted August 15, 2012 Tell us what game it is, then we might be able to help... Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369651 Share on other sites More sharing options...
ignace Posted August 15, 2012 Share Posted August 15, 2012 So you have an open-source game on YOUR webserver. Where you have access to THE DATABASE. You want to create a bot that does some stuff so that you can gain... resources?! Run this in phpmyadmin: UPDATE players SET gold = gold + 99999999, iron = iron + 99999999, .. WHERE id = your-id Refresh the page (or logout/login) and voila 99M gold, iron, .. Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369662 Share on other sites More sharing options...
Mahngiel Posted August 15, 2012 Share Posted August 15, 2012 So you have an open-source game on YOUR webserver. Where you have access to THE DATABASE. You want to create a bot that does some stuff so that you can gain... resources?! Run this in phpmyadmin: UPDATE players SET gold = gold + 99999999, iron = iron + 99999999, .. WHERE id = your-id Refresh the page (or logout/login) and voila 99M gold, iron, .. I am Mahn for president, and I approve this message! Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369683 Share on other sites More sharing options...
Captain09 Posted August 15, 2012 Author Share Posted August 15, 2012 its a browsergame which is similar like travian Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369712 Share on other sites More sharing options...
Captain09 Posted August 16, 2012 Author Share Posted August 16, 2012 So you have an open-source game on YOUR webserver. Where you have access to THE DATABASE. You want to create a bot that does some stuff so that you can gain... resources?! Run this in phpmyadmin: UPDATE players SET gold = gold + 99999999, iron = iron + 99999999, .. WHERE id = your-id Refresh the page (or logout/login) and voila 99M gold, iron, .. that WOULD work but I want a bot and not giving players resources Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369762 Share on other sites More sharing options...
MMDE Posted August 16, 2012 Share Posted August 16, 2012 So you have an open-source game on YOUR webserver. Where you have access to THE DATABASE. You want to create a bot that does some stuff so that you can gain... resources?! Run this in phpmyadmin: UPDATE players SET gold = gold + 99999999, iron = iron + 99999999, .. WHERE id = your-id Refresh the page (or logout/login) and voila 99M gold, iron, .. that WOULD work but I want a bot and not giving players resources Sorry if this sounds a bit rude, but you need to think a little, maybe outside the box. They just told you how to fix this problem. Why do you want to make a bot? If you got full access to the server, then you could set a cron job (just like you said) to do what you said you want. Just write it to do what you want with full access to the server, and run it on the server side, because that's what PHP is for. This is just what they told you to do. If you want users to be able to use it too, then you may just let them access the same service. If what you on the other hand want to is to create a bot that can be used on another site that runs the same open-source game, then that's a totally different matter. All you probably would need is cURL and PCRE functions, or maybe if you want use the DOMDocument class. To see the post/get/header data sent, use Live HTTP headers add-on for firefox, then you can mimic it with cURL. This will help you with what you request. I could probably write one in like 15 minutes if you just tell me the game, as I requested earlier. >_> Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369770 Share on other sites More sharing options...
tibberous Posted August 16, 2012 Share Posted August 16, 2012 Get the Firebug extension if you don't already have it - it can be a huge help in reverse-engineering certain things. It has a feature called "Inspect Element" that you can use on images and buttons to try to get the javascript they call. And yeah, I can see how a bot that mimics a player could be needed. People want to be attacked by a player with an army and different units -- not the same as just changing the amount of shit they have with no reason why. Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369774 Share on other sites More sharing options...
Mahngiel Posted August 16, 2012 Share Posted August 16, 2012 We're all pulling teeth and grasping at straws here. Either OP explains what is really going on or we're just spinning our wheels. Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369775 Share on other sites More sharing options...
xyph Posted August 16, 2012 Share Posted August 16, 2012 If you want to help this guy cheat, please do so in PMs. Quote Link to comment https://forums.phpfreaks.com/topic/267089-bot-with-php/#findComment-1369881 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.