Jump to content
Sign in to follow this  
redfire

API Hooking and Sending Data , POST

Recommended Posts

redfire

Hello everyone, 

I spent the whole Night on research and the rest, I was looking for a way in order to do this, Kindly look and correct.

#include winhttp.au3
#include hooking.au3
#include winapi.au3


Global $hHook,$hProc
Global $pString[2] = [0,0]
Global $hSession
Global $sProcessName ="iexplorer.exe"


SetPriviledge("SeDebugPriviledge",1)
$data = _WinApi_GetProcess(_WinAPI_GetModuleHandle("kernel32.dll"),"GetModuleHandleA")
$data = _WinApi_GetProcess(_WinApi_GetModuleHandle("kernel32.dll"),"GetProcAddress")
$data = _WinApi_GetProcess(_WinAPI_GetModuleHandle("wininet.dll"),"InternetOpenA")
$data = _WinApi_GetProcess(_WinAPI_GetModuleHandle("wininet.dll"),"InternetConnectA")
$data = _WinApi_GetProcess(_WinApi_GetModuleHandle("wininet.dll"),"HttpOpenRequestA")
$data = _WinApi_GetProcess(_WinApi_GetModuleHandle("kernel32.dll"),"VirtualProtect")
$data = _WinApi_GetProcess(_WinApi_GetModuleHandle("kernel32.dll"),"Sleep")

Global $hSession = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)")
$hConnect = _WinHttpConnect($hSession,"www.google.com")
Local $sHTML = _WinHttpSimpleRequest($hConnect, "POST", "data.php", "www.google.com", $data)

I want it to get data, and send to the "data.php" section, how do i go from here

Edited by redfire

Share this post


Link to post
Share on other sites
water

I don't get what you try to achieve ("want it to get data" - which data?) but you overwrite the data by each call to _WinAPI_GetProcess.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
redfire

I don't get what you try to achieve ("want it to get data" - which data?) but you overwrite the data by each call to _WinAPI_GetProcess.

 

Data from a browser Process, i think i get it now. then it then means i have to string it with different variables other than $data to replace all, think i call it $data1,$data2 etc then put all of them into a full string like this :

$maindata = "$data1,$data2,$data3....." etc..

Kindly correct me if i am wrong.

Share this post


Link to post
Share on other sites
water

Do it in one go:

$data = _WinApi_GetProcess(_WinAPI_GetModuleHandle("kernel32.dll"),"GetModuleHandleA")
$data = $data & "," & _WinApi_GetProcess(_WinApi_GetModuleHandle("kernel32.dll"),"GetProcAddress")

etc.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
redfire

Do it in one go:

 

See what i mean,

#include <WinHttp.au3>
#include <hooking.au3>
#include <winapi.au3>


Global $hHook,$hProc
Global $pString[2] = [0,0]
Global $hSession
Global $sProcessName ="iexplorer.exe"


SetPriviledge("SeDebugPriviledge",1)
$data1 = _WinApi_GetProcess(_WinAPI_GetModuleHandle("kernel32.dll"),"GetModuleHandleA")
$data2 = _WinApi_GetProcess(_WinApi_GetModuleHandle("kernel32.dll"),"GetProcAddress")
$data3 = _WinApi_GetProcess(_WinAPI_GetModuleHandle("wininet.dll"),"InternetOpenA")
$data4 = _WinApi_GetProcess(_WinAPI_GetModuleHandle("wininet.dll"),"InternetConnectA")
$data5 = _WinApi_GetProcess(_WinApi_GetModuleHandle("wininet.dll"),"HttpOpenRequestA")
$data6 = _WinApi_GetProcess(_WinApi_GetModuleHandle("kernel32.dll"),"VirtualProtect")
$data7 = _WinApi_GetProcess(_WinApi_GetModuleHandle("kernel32.dll"),"Sleep")

$alldata = "$data1,$data2,$data3,$data4,$data5,$data6,$data7"

Global $hSession = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)")
$hConnect = _WinHttpConnect($hSession,"www.google.com")
Local $sHTML = _WinHttpSimpleRequest($hConnect, "POST", "data.php", "www.google.com", $alldata)

Maybe you could please Check with your Own auto IT Ide and correct the errors here. Please. Would be appreciated.

Share this post


Link to post
Share on other sites
water

This statement is wrong:

$alldata = "$data1,$data2,$data3,$data4,$data5,$data6,$data7"

The variables are treated as literals.

Either use the solution i proposed above or:

$alldata = $data1 & "," & $data2 & "," & $data3 & "," & $data4 & "," & $data5 & "," & $data6 & "," & $data7

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

BTW:
I suggest to first learn the basics about AutoIt before you try to solve such a complex problem.

The help file (the first few chapters) and the tutorials you can find in the Wiki are a good starting point.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
redfire

I have been able to look into my codes and corrected some mistakes i saw, but I still see something like this flagging an error 

$data1 = _WinApi_GetProcess(*****)

 and it tells me unknown function name. I checked with the includes and saw the file there. What could the problem be? why is it not seeing the functions?

Share this post


Link to post
Share on other sites
water

Which version of AutoIt do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
redfire

I run Auto IT for version v3.3.8.1

Um, does it have any problem?

Share this post


Link to post
Share on other sites
water

If you check the help file for the WinAPI UDF you will notice that there is no _WinApi_GetProcess function. So where did you find it?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
redfire

i didnt see it there, by the way i ran the program using the Beta, it shows duplicate process function. I am wondering what the main problem is, or where it could be from, kindly compile using the beta and let me know where the error is from.

Share this post


Link to post
Share on other sites
water

add "#include-once" at the top of your script and see if the error goes away.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
redfire

add "#include-once" at the top of your script and see if the error goes away.

 

Sorry still gives the same problem, duplicate function name.

Here is my source code,

#include-once
#include <WinHttp.au3>
#include <hooking.au3>
#include <winapi.au3>


Global $hHook,$hProc
Global $pString[2] = [0,0]
Global $hSession
Global $sProcessName ="iexplorer.exe"


;SetPriviledge("SeDebugPriviledge",1)
$data1 = _WinApi_GetProcess(_WinAPI_GetModuleHandle("kernel32.dll"),"GetModuleHandleA")
$data2 = _WinApi_GetProcess(_WinApi_GetModuleHandle("kernel32.dll"),"GetProcAddress")
$data3 = _WinApi_GetProcess(_WinAPI_GetModuleHandle("wininet.dll"),"InternetOpenA")
$data4 = _WinApi_GetProcess(_WinAPI_GetModuleHandle("wininet.dll"),"InternetConnectA")
$data5 = _WinApi_GetProcess(_WinApi_GetModuleHandle("wininet.dll"),"HttpOpenRequestA")
$data6 = _WinApi_GetProcess(_WinApi_GetModuleHandle("kernel32.dll"),"VirtualProtect")
$data7 = _WinApi_GetProcess(_WinApi_GetModuleHandle("kernel32.dll"),"Sleep")

$alldata = $data1 & "," & $data2 & "," & $data3 & "," & $data4 & "," & $data5 & "," & $data6 & "," & $data7

Global $hSession = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)")
$hConnect = _WinHttpConnect($hSession,"www.google.com")
Local $sHTML = _WinHttpSimpleRequest($hConnect, "POST", "data.php", "www.google.com", $alldata)

Share this post


Link to post
Share on other sites
water

Each error message in AutoIt comes with a line number. This should get you started.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
redfire

This area,

Global $hHook,$hProc

I wonder why it gives those funny errors.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×