For this tutorial I am going to be using C#. However, you can easily transfer this over into any other language if you have a basic understanding of what you are doing. I am also going to be using a modified version of HTTPWrappers that you can find in here.
Requirements
- Live HTTPHeaders or HTTPFox (or some other web browser add-on that captures HTTP Streams).
- HTTPWrappers or Sockets that support HTTP Browsing / Streaming.
Here we will be using two methods in order to give you a general idea of how to create bots through the POST and GET method.
For these examples we are going to be using a custom PHP Script called login.php to demonstrate how a basic log in works with web sites.
There is a hidden value that we need to obtain in order to log into the website.
First what you will want to do is browse to the web site into your browser and log into the web site like you would normally except you will want to be running the add-on HTTPFox (or any other HTTP Stream capture program you are using). This will let you grab any information that you need to log into the website such as the URL and Post Data. Remember to look for an identifier to see if you are logged in (gold amount, welcome messages, etc)...
From the information we have gathered we can see that we are going to need to find the following variables.
Pretty simple, however we are challenged to find this 'secret' value in order to log in or else it wont work! Now that we know the information we can start programming our bot.Code:URL to Login: http://localhost/login.php username password secret Welcome back!
Open up your desired programming language and create a new project. Include any files that you might need such as the HTTPWrapper.cs file.
You will then want to create an instance of the HTTPWrapper files to use. The following will look like such in C#.net
PHP Code:
HTTPWrapper.HTTPInterface Wrapper = new HTTPWrapper.HTTPInterface();
So now we are left with the following code in our project.
PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LG_Tutorial_Bot
{
class Program
{
static HTTPWrapper.HTTPInterface Wrapper = new HTTPWrapper.HTTPInterface();
static void Main(string[] args)
{
}
}
}
So now that we are here we need grab our secret value by first browsing to the web site and grabbing this value from the HTML source. To do so we are going to use our GetStringBetween function in our HTTPWrappers.
Browsing to the website
Next we need to grab that 'secret' and store it into a value in order to use it in the near future.PHP Code:
string HTML = Wrapper.Get("http://localhost/login.php");
PHP Code:
string Secret = Wrapper.Between(HTML, "secret\" value=\"", "\"");
Some clarification; I am using back slashes in order to escape the quotation marks to emulate the code to say, "Hey, there are some quotes here so I can include these in the code!" Without these we wouldn't be able to grab our secret value.
Your code should now look something a long the lines of
PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LG_Tutorial_Bot
{
class Program
{
static HTTPWrapper.HTTPInterface Wrapper = new HTTPWrapper.HTTPInterface();
static void Main(string[] args)
{
string HTML = Wrapper.Get("http://localhost/login.php");
string Secret = Wrapper.Between(HTML, "secret\" value=\"", "\"");
}
}
}
Well now that we have this 'secret' value, what do we do? Now we simply post the rest of our data to a string and post it to the website and check for the identifier to see if we have successfully logged in!
Let me clarify this information so you can see what it is going to look like. The Wrapper.Post function requires the following fields;
URL, PostData, Referrer (optional). Some sites require the Referrer or it wont work, thankfully we do not need this.
So we will be posting the following information as such;
Code:URL: http://localhost/login.php PostData: username= USERNAME password= PASSWORD secret= SECRET VALUE
This is how the following code should look
& is used after any value (as long as it is not the first value) in the post data string or else it will not work.PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LG_Tutorial_Bot
{
class Program
{
static HTTPWrapper.HTTPInterface Wrapper = new HTTPWrapper.HTTPInterface();
static void Main(string[] args)
{
string HTML = Wrapper.Get("http://localhost/login.php");
string Secret = Wrapper.Between(HTML, "secret\" value=\"", "\"");
Console.WriteLine("Username: ");
string Username = Console.ReadLine();
Console.WriteLine("Password: ");
string Password = Console.ReadLine();
string Post_Data = Wrapper.Post("http://localhost/login.php", "username=" + Username + "&password=" + Password + "&secret=" +Secret);
}
}
}
Now that we have successfully posted this information to the website, how do we tell that we have successfully logged in?
Simple! We check for the identifier "Welcome back!"
The ending result should leave us withPHP Code:
if(Post_Data.Contains("Welcome back!"){
Console.WriteLine("Logged in!");
}else{
Console.WriteLine("Failed to login....");
}
PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LG_Tutorial_Bot
{
class Program
{
static HTTPWrapper.HTTPInterface Wrapper = new HTTPWrapper.HTTPInterface();
static void Main(string[] args)
{
string HTML = Wrapper.Get("http://localhost/login.php");
string Secret = Wrapper.Between(HTML, "secret\" value=\"", "\"");
Console.WriteLine("Username: ");
string Username = Console.ReadLine();
Console.WriteLine("Password: ");
string Password = Console.ReadLine();
string Post_Data = Wrapper.Post("http://localhost/login.php", "username=" + Username + "&password=" + Password + "&secret=" +Secret);
if(Post_Data.Contains("Welcome back!")){
Console.WriteLine("Logged in!");
}else{
Console.WriteLine("Failed to login....");
}
}
}
}
After some cleaning and optimization we would come up with this (OPTIONAL)
PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LG_Tutorial_Bot
{
class Program
{
static HTTPWrapper.HTTPInterface Wrapper = new HTTPWrapper.HTTPInterface();
static void Main(string[] args)
{
bool status = false;
while (status == false)
{
Console.WriteLine("Username: ");
string Username = Console.ReadLine();
Console.WriteLine("Password: ");
string Password = Console.ReadLine();
if (Wrapper.Post("http://localhost/login.php", "username=" + Username + "&password=" + Password + "&secret=" + Wrapper.Between(Wrapper.Get("http://localhost/login.php"), "secret\" value=\"", "\"")).Contains("Welcome back!"))
{
Console.WriteLine("Logged in!");
status = true;
}
else
{
Console.WriteLine("Failed to login....");
}
}
Console.ReadLine();
}
}
}
login.php (Username = LogicalGamers, Password = admin)
if you wish to copy exactly what I did, I am running a home server with WAMP and the following saved as login.php.PHP Code:
<html>
<title>Post Example</title>
<body>
<?php
if(isset($_COOKIE['status'])){
print "Welcome back!";
}else{
?>
<form name="authentication" action="login.php" method="post">
Username: <input type="text" name="username"><br />
Password: <input type="password" name="password"><br />
<input type="hidden" name="secret" value="<?php echo rand(9999, 999999); ?>"/>
<input type="submit" value="Login">
</form>
<?php
}
?>
</body>
</html>
<?php
if(isset($_POST['secret'])){
if( (isset($_POST['username'])) && (isset($_POST['password'])) ){
if( (strtolower($_POST['username']) == 'logicalgamers'){
if($_POST['password'] == 'admin'){
print "Welcome, " . $_POST['username'];
setcookie('status', md5(md5($_POST['username'] + time())), time() + 1800);
}else{
print "Incorrect password!";
}
}else{
print "Username does not exist!";
}
}
}
?>
Results 1 to 8 of 8
- 08 Jan. 2014 12:48am #1
[Tutorial] Creating bots with HTTP Wrappers
- 08 Jan. 2014 12:59am #2
Cool tut. We need more guides like this that teach people the bare-bones of things like bot making. HTTP requests are one of the most common things ever.
I like how you sprinkled a little php in there, too.I'm lightning on my feet
- 14 Jan. 2014 10:26pm #3
- Join Date
- Apr. 2013
- Location
- Minnesota
- Posts
- 1,325
- Reputation
- 114
- LCash
- 0.00
+rep cause you need it bro <3
Thanks for the tut, interesting to see things written in c#.
I would use python for teaching.https://discord.gg/TvN6xUb ~ chat on discord pls.
- 14 Jan. 2014 10:46pm #4
Moderator Bachelor of Science in Virginity
- Age
- 31
- Join Date
- Nov. 2009
- Location
- Toronto
- Posts
- 5,421
- Reputation
- 546
- LCash (Rank 3)
- 1.96
- 14 Jan. 2014 11:22pm #5
- 16 Jan. 2014 06:36am #6
- Join Date
- Apr. 2013
- Location
- Minnesota
- Posts
- 1,325
- Reputation
- 114
- LCash
- 0.00
Coming from java I had a really easy time implementing wrappers.
I do miss the brackets and not being anal about whitespace.https://discord.gg/TvN6xUb ~ chat on discord pls.
- 25 Jan. 2014 03:45pm #7
To those who this might be of some sort of help: VB.net s HTTPwrappers thoroughly explained (tought I don't know if LG's logging requests are still the same :p)
Last edited by ~Shieru No Tamashi~; 25 Jan. 2014 at 03:47pm.
- 26 Jan. 2014 02:51pm #8
- Join Date
- Jan. 2014
- Location
- C:/Users/Unknown/porn
- Posts
- 123
- Reputation
- 9
- LCash
- 0.00
Im not really a much of a programer
so i really have zero idea of whats going on it this tut
Can anyone make a Idiots Guide or video?
I will highly appreciate it