Jump to content

API Hooking and Sending Data , POST


Recommended Posts

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
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Which version of AutoIt do you run?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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)
Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...