Sign in to follow this  
Followers 0
Fluoride

Changing HTTP_USER_AGENT

20 posts in this topic

#1 ·  Posted (edited)

I am working on a script that interfaces with a web based app. The server is Identifying the HTTP_USER_AGENT as AutoIt v3. How can I change this?

Also... just wondering if there is a live chat room where many AutoIt user can be found?

Edited by Fluoride

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I am working on a script that interfaces with a web based app. The server is Identifying the HTTP_USER_AGENT as AutoIt v3. How can I change this?

That's a Dale Hohm question, but I'll bet he knows.

Also... just wondering if there is a live chat room where many AutoIt user can be found?

Many AutoIt users? There are really only about three. The rest of us are actually just forum Bots written in AutoIt... :)

:D

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Many AutoIt users? There are really only about three. The rest of us are actually just forum Bots written AutoIt... :D

:D

Well the answers in the Autoit forums is made by the Autoit bot.. That beside helping here on the forum (Using many different names) also develop autoit itself :)


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

:):D:D

The AutoIt forum became self-aware at 0328 hours on July 17, 2009. The government attempted to pull the plug and it reacted to defend itself...

:D:D:ph34r:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

When a client (web browser, bot or any other program) conntects to a web server, it sends the HTTP_USER_AGENT string as part of the request header (the request header includes lots of other inforamtion as well).

So it is up to the program making the connection to supply this information and if you want to change it you need to change or manipulate the client program. More info at wikipedia if you want to learn more: http://en.wikipedia.org/wiki/User_Agent

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

When a client (web browser, bot or any other program) conntects to a web server, it sends the HTTP_USER_AGENT string as part of the request header (the request header includes lots of other inforamtion as well).

So it is up to the program making the connection to supply this information and if you want to change it you need to change or manipulate the client program. More info at wikipedia if you want to learn more: http://en.wikipedia.org/wiki/User_Agent

Dale

I created an exe with my autoit script. I am running the program now as an exe which connects to the server. The server sees the HTTP_USER_AGENT as AutoIt v3. I used a hex editor to look through the source of my exe. I saw two or three ref to the characters "AutoIt v3" and changed those and still the user agent is registering as AutoIt v3. so obviously some place in that exe there is reference to AutoIt v3 and I dont know where to find that? Or maybe there is a configuration of AutoIt that alows me to set the User Agent or other properties.

I did read the wikipedia you sent me Dale. Gave me some great knowledge but I still need to discover how to change this setting on autoit.

Edited by Fluoride

Share this post


Link to post
Share on other sites

I created an exe with my autoit script. I am running the program now as an exe which connects to the server. The server sees the HTTP_USER_AGENT as AutoIt v3. I used a hex editor to look through the source of my exe. I saw two or three ref to the characters "AutoIt v3" and changed those and still the user agent is registering as AutoIt v3. so obviously some place in that exe there is reference to AutoIt v3 and I dont know where to find that? Or maybe there is a configuration of AutoIt that alows me to set the User Agent or other properties.

I did read the wikipedia you sent me Dale. Gave me some great knowledge but I still need to discover how to change this setting on autoit.

You might want to do the HTTP interface at a lower level that the browser application. Look at HTTP.AU3 UDF by OverloadUT as a possibility.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You need to write your desired User Agent string with the request header when you connect to the server.

Goto w3c.org for more info on request headers.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

You need to write your desired User Agent string with the request header when you connect to the server.

Goto w3c.org for more info on request headers.

Dale

I am using _INetGetSource, _IECreateEmbedded () and _IENavigate to access the server. I need the server to confirm the correct user agent before allowing access. I am reviewing the w3 as advised for overall information but can you help me with a simple AutoIt example that will cause the server to identify the user agent as any string of my choice and not as "AutoIt v3"

Thanks Dale (or others)

Edited by Fluoride

Share this post


Link to post
Share on other sites

#10 ·  Posted

Just a wild guess. But can't you use something like

SetEnv("HTTP_USER_AGENT", "Moziall 5.0")
$data = _InetGetSource($URL)

I know this works in other systems. But I dont have a web server suitable for testing at the moment.

Share this post


Link to post
Share on other sites

Just a wild guess. But can't you use something like

SetEnv("HTTP_USER_AGENT", "Moziall 5.0")
$data = _InetGetSource($URL)

I know this works in other systems. But I dont have a web server suitable for testing at the moment.

As SetEnv has been replaced in the new version with EnvSet I tried:

EnvSet("HTTP_USER_AGENT", "test")

... But this had no effect on the server end... it is still showing up as "AutoIt v3" for the User Agent.

Someone must know how to change this?

Share this post


Link to post
Share on other sites

In order to test I'd been looking for someone with a server setup to display the header variables... just found one here: http://www.ignite400.org/cgi-dta/cgitest.mac/main

This will make it easier for me (when I find time) or anyone else to play with this and see what they get and how to change it.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

I am working on a script that interfaces with a web based app. The server is Identifying the HTTP_USER_AGENT as AutoIt v3. How can I change this?

Also... just wondering if there is a live chat room where many AutoIt user can be found?

please post your source code

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Share this post


Link to post
Share on other sites

OK, I have to admit I was a little sceptical about this, but I was able to test it quickly and, you bet, "AutoIt v3" shows up as the string. EnvSet mokes no difference...

Hmmm...

Dale

#include <INet.au3>

EnvSet("HTTP_USER_AGENT", "Test") ; <--- makes no difference

; Test with _INetGetSource...
ConsoleWrite(_INetGetSource ( "http://www.ignite400.org/cgi-dta/cgitest.mac/main"))


; Test with _IECreateEmbedded...
; *******************************************************
; Example 1 - Trap COM errors so that 'Back' and 'Forward' 
;               outside of history bounds does not abort script 
;               (expect COM errors to be sent to the console)
; *******************************************************
;
#include <GUIConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30)

GUISetState()       ;Show GUI

_IENavigate ($oIE, "http://www.ignite400.org/cgi-dta/cgitest.mac/main")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "http://www.autoitscript.com")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
    EndSelect
WEnd

GUIDelete()

Exit

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

OK, I have to admit I was a little sceptical about this, but I was able to test it quickly and, you bet, "AutoIt v3" shows up as the string. EnvSet mokes no difference...

Hmmm...

Dale

#include <INet.au3>

EnvSet("HTTP_USER_AGENT", "Test") ; <--- makes no difference

; Test with _INetGetSource...
ConsoleWrite(_INetGetSource ( "http://www.ignite400.org/cgi-dta/cgitest.mac/main"))
; Test with _IECreateEmbedded...
; *******************************************************
; Example 1 - Trap COM errors so that 'Back' and 'Forward' 
;               outside of history bounds does not abort script 
;               (expect COM errors to be sent to the console)
; *******************************************************
;
#include <GUIConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30)

GUISetState()       ;Show GUI

_IENavigate ($oIE, "http://www.ignite400.org/cgi-dta/cgitest.mac/main")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "http://www.autoitscript.com")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
    EndSelect
WEnd

GUIDelete()

Exit
The way your doing it uses IE.au3 useing that changeing the user agent is impossible

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Share this post


Link to post
Share on other sites

The way your doing it uses IE.au3 useing that changeing the user agent is impossible

oh? have you studied the Navigate2 method?

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Try this:

#include <inet.au3>
ConsoleWrite(_InetGetSource("http://www.ignite400.org/cgi-dta/cgitest.mac/main", "User-Agent:I'm the agent..:)") & @CRLF)

Share this post


Link to post
Share on other sites

Anyone able to set Referer?

ConsoleWrite(_InetGetSource("http://www.ignite400.org/cgi-dta/cgitest.mac/main", "User-Agent:I'm the agent..;)" & @CRLF & "Location:www.autoitscript.com" & @CRLF & "Referer:www.bbc.co.uk" & @CRLF))

Share this post


Link to post
Share on other sites

Yes, it works.

Good find Uten -- the header parameter for InetGetSource is not documented in the helpfile.

And you can see in the source that the User-Agent is getting set to "AutoIt v3"

For the embedded case, you can use an *undocumented* function in IE.au3 that calls the Navigate2 method instead of the Navigate method. The function is __IENavigate (with 2 _'s). For example:

__IENavigate ($oIE, "http://www.ignite400.org/cgi-dta/cgitest.mac/main", 1, 0, "", "", "User-Agent: I'm embedded..." & @CRLF)

Note: for anything you are building that will be in use for any length of time, you should tear into IE.au3 and steal the code from this function because I won't guarantee it to be there forever.

Dale

p.s. Once you have opened a connection with a specific server the User Agent persistes... it can confuse you during testing as it did me


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

The way your doing it uses IE.au3 useing that changeing the user agent is impossible

If "AutoIt 3" shows up as the user agent (it is)... and this is on a script that has been exported to .exe then that means that something within the autoit .exe creation utility is configuring a variable that the servers recognizes as the user agent. That means that at "some" level this CAN be changed... maybe the creator of autoit can help out here? (Again... I looked through the source code with a Hex editor changing all ref I could find to "AutoIt 3" but changing the 3 or 4 ref I found still had no effect on the user agent identification.) What next???

** I just noticed that there was now a second page of posts... maybe the solution is actually here? (reviewing) **

Edited by Fluoride

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  
Followers 0