Bridging:
First of all let's start at the beginning.. in order to let modules communicate with each other you will need to understand how they work.
Most modules in THC_HS have the ability to run as a background task, this is interesting as you will be able to run several tasks next to each other, modules like these can be used
for bridging.
Bridging in this case is simply the communication between two modules, the most essential of all the modules is definitely THC_SS which can poll targets for results each x seconds, although you can
definitely write your own modules that can communicate with other modules too.
Tasks:
Tasks are not 100% essential but they do allow some useability that other modules without it just can't offer.
When a task runs it's inserted into $_PATHS['data_root']/running.txt, here's an example of the content:
thc_sb|1313672136|1313672187|1
thc_sb|1313672287|0|0
These are two separate tasks, the first is a completed task, the last is a running task.
Let's break it down:
thc_sb|1313672136|1313672187|1
thc_sb: the module that is running
1313672136: timestamp when the task started
1313672187: timestamp when the task completed
1: the task is completed
Now that we know this let's code something simple, we'll bridge THC_SB with THC_SS in order to mail us the results when the task has completed.
Let's setup a plan first:
1- find a way to send the request to the module
2- monitor the task
3- get results when done
4- mail them
For the communication we only need to know what the form sends to where and how, that is easy, when you look at the form this is the structure:
<form method="post" class="spacing" action="http://127.0.0.1/thc_hacksuite/thc_sb/screen.php" target="screen">
<table border=0 width="500">
<tr><td>year range</td><td>
<select multiple name="aYear[ ]">
<optgroup label="router manufacture year ">router manufacture year</optgroup>
<option value="2005">2005</option>
<option value="2006" selected>2006</option>
<option value="2007" selected>2007</option>
<option value="2008" selected>2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
</select></td></tr>
<tr><td>bssid</td><td><input type="text" name="sInput" value="f8a3d0">
</select></td></tr>
<tr><td colspan=2><input type="submit" name="submit" value="Bruteforce"> <input type="submit" name="submit" value="Dump File"></td></tr>
</table>
</form>That's easy enough to send using sockets or curl, we'll use the latter method:
<?php
$aYear = array("2007","2008","2009","2010","2011");
$ch = curl_init();
// your url could be different, just check the source
curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1/thc_hacksuite/thc_sb/screen.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "aYear[]=2007&aYear[]=2008&aYear[]=2009&aYear[]=2010&aYear[]=2011&sInput=f8a3d0&submit=Bruteforce");
$sResult = curl_exec($ch);
curl_close($ch);
?>I'm not going into the validation of the array...it's easy enough to rewrite so that you will be able to set the years yourself in here, this is merely a POC.
So what's next?
Well let's first see if it works correctly by making a small script that outputs the post variables.
<?php
var_dump($_POST);
?>I've changed the Curl url to a test file..this is the output for the above post fields that were posted.
Note that I placed an echo for $sResult or else you would get a blank page.
array(3) {
["aYear"]=>
array(5) {
[0]=>
string(4) "2007"
[1]=>
string(4) "2008"
[2]=>
string(4) "2009"
[3]=>
string(4) "2010"
[4]=>
string(4) "2011"
}
["sInput"]=>
string(6) "f8a3d0"
["submit"]=>
string(10) "Bruteforce"
}As you can see this works without a hitch, now we know that we can make this script running, all we need is a script that polls the task file, this is pretty easy as the cms allows
you to code it with a few lines of code:
<?php
if(!function_exists("RawToArray")){
include($_PATHS['functions_root']."/raw_to_array.php");
}
$sModuleToPoll = "thc_sb";
$aTask = array();
// the task file is predefined in the paths variable
if(@filesize($_PATHS['task_file'])>0){
if(false!==($aFileData = RawToArray($_PATHS['task_file']))){
// the last entry in the task file should be the task we're after
$iItem = count($aFileData)-1;
if($aFileData[$iItem][0]!=$sModuleToPoll){
die("Expecting last entry to be a task for ".$sModuleToPoll);
}
$aTask = $aFileData[$iItem];
}
else{
die("No tasks are running");
}
}
else{
die("Empty task file");
}
?>If all went well we should now have an array that contains the properties for the task we just started through the curl request.
Well that's basically all we need to get our job done... the rest is about creating a callback in THC_SS, which I will do later...stay tuned.
I'm a motherfucker..but still cute! ![]()
:bump: No updates yet?
Too busy but I'm sure you can stitch the missing part of this tutorial with the tutorial in current form, not sure when I'll finish it.
I'm a motherfucker..but still cute! ![]()