Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Auto-Fill Web Browser Log In. Username does not exist when auto-filled

So I'm trying to create a web browser auto-login with a button. I have tried setting innertext, and attributes to my Username and Password;however, when I click Log In the website gives me an error saying that the user does not exist. If I C+P the username from the code it works just fine, not sure what to do about this. I have tried different methods of inserting the username and same shit. Any help is appreciated.

Code
Dim Username As HtmlElement
Dim Password As HtmlElement

WebBrowser1.Document.GetElementById("password").SetAttribute("value", "password")
        Dim elements As HtmlElementCollection = WebBrowser1.Document.All.GetElementsByName("username")
        For Each element As HtmlElement In elements
            element.SetAttribute("value", "420Alt")
        Next
(Aug 15, 2017 11:12 AM)Moon Rock Wrote:  So I'm trying to create a web browser auto-login with a button. I have tried setting innertext, and attributes to my Username and Password;however, when I click Log In the website gives me an error saying that the user does not exist. If I C+P the username from the code it works just fine, not sure what to do about this. I have tried different methods of inserting the username and same shit. Any help is appreciated.

Code
Dim Username As HtmlElement
Dim Password As HtmlElement

WebBrowser1.Document.GetElementById("password").SetAttribute("value", "password")
        Dim elements As HtmlElementCollection = WebBrowser1.Document.All.GetElementsByName("username")
        For Each element As HtmlElement In elements
            element.SetAttribute("value", "420Alt")
        Next

Have you checked if the values are actually getting set? Just put the WebBrowser visible in the designer somewhere.
There are certain forms out there on the internet that will not accept a value set through SetAttribute and actually require a KeyPress event to fire in order for the value to go "into play". I'm not saying this is happening for you as I have no idea what site you're working on, just making you aware that could be a cause of your issue, though I doubt it. Good luck!
Need a custom software? Check out my freelance service here! 6+ years and counting, never a complaint :)

STOP STEALING CODE.

FREE NATHAN

People who report posts are lamers.
(Aug 15, 2017 05:05 PM)idb. Wrote:  There are certain forms out there on the internet that will not accept a value set through SetAttribute and actually require a KeyPress event to fire in order for the value to go "into play". I'm not saying this is happening for you as I have no idea what site you're working on, just making you aware that could be a cause of your issue, though I doubt it. Good luck!

I guess I will do the keypress events. I was thinking about it also using tab to initiate it.

(Aug 15, 2017 02:44 PM)Ninja Wrote:  Have you checked if the values are actually getting set? Just put the WebBrowser visible in the designer somewhere.

The values are being set, I can see it through the WebBrowser. When I C+P from the WebBrowser it comes out just fine in notepad.
(Aug 15, 2017 05:11 PM)Moon Rock Wrote:  I guess I will do the keypress events. I was thinking about it also using tab to initiate it.


The values are being set, I can see it through the WebBrowser. When I C+P from the WebBrowser it comes out just fine in notepad.

So the textboxes in the form on the website are getting set? Then there is no use for keypress events.
(Aug 15, 2017 05:40 PM)Ninja Wrote:  So the textboxes in the form on the website are getting set? Then there is no use for keypress events.

The textboxes are being set on the website. However once I click Login it claims the user does not exist.

I just changed my code to KeySend for the textboxes and it works perfectly fine. I don't really like doing it this way, but I guess it'll work for now.
(Aug 15, 2017 05:44 PM)Moon Rock Wrote:  The textboxes are being set on the website. However once I click Login it claims the user does not exist.

I just changed my code to KeySend for the textboxes and it works perfectly fine. I don't really like doing it this way, but I guess it'll work for now.

Maybe it for some reason set the placeholder for the textbox and not the actual value? Weird... anyways, good job on solving it!
(Aug 15, 2017 05:44 PM)Moon Rock Wrote:  The textboxes are being set on the website. However once I click Login it claims the user does not exist.

I just changed my code to KeySend for the textboxes and it works perfectly fine. I don't really like doing it this way, but I guess it'll work for now.

Their can be possibility of focusout event firing on that textfield to check username?
(Aug 15, 2017 05:40 PM)Ninja Wrote:  So the textboxes in the form on the website are getting set? Then there is no use for keypress events.

Inaccurate information.

(Aug 15, 2017 05:44 PM)Moon Rock Wrote:  The textboxes are being set on the website. However once I click Login it claims the user does not exist.

I just changed my code to KeySend for the textboxes and it works perfectly fine. I don't really like doing it this way, but I guess it'll work for now.

Hoping you're not using SendKeys. You can use actual windows API to fill forms in a webbrowser, you just need to target the handle of the embedded browser object. You may want to look into pasting into the field too (you can use ExecCommand for this). Good luck!
Need a custom software? Check out my freelance service here! 6+ years and counting, never a complaint :)

STOP STEALING CODE.

FREE NATHAN

People who report posts are lamers.
(Aug 16, 2017 03:59 AM)idb. Wrote:  Inaccurate information.


Hoping you're not using SendKeys. You can use actual windows API to fill forms in a webbrowser, you just need to target the handle of the embedded browser object. You may want to look into pasting into the field too (you can use ExecCommand for this). Good luck!

Oh thank God at least someone gets it!
You could also look into webbrowser extension development since it would be an excellent project for such a thing. That is if you're making a lastpass alternative.

Why anyone would use a webbrowser control for anything besides making your own 'webbrowser' for learning purposes is beyond me. It uses Internet Explorer for gods sake. Why is that bad, you may ask? To start with IE is incredibly dated, it will not support certain JS functions and will thus result in compatibility issues. Any webdev knows this and any webdev will recommend you to NOT use IE at all. Second, if you're not showing the webbrower control to the user then what exactly is the point even? This control was developed to allow your user to visit a help page for example, or to learn you some basics.

You can make your own webbrowser using built in .net classes or go beyond that. Go deeper. Anyway, please just use the Gecko or webkit. Do yourself a favor.

To log-in all you actually have to do is 'follow the money' so to speak. Look where the information is posted to, and use that service/api. I know all about hidden fields that try and stop this but you can still circumvent this. Lol.
Even captcha's can be mitigated using certain tactics by for example showing the user the captcha and making the user fill it in.. Remember that tokens can be generated by you..
(Aug 16, 2017 08:13 PM)DeadKube Wrote:  Why anyone would use a webbrowser control for anything besides making your own 'webbrowser' for learning purposes is beyond me.

Because for people beginning in web-botting it is easier.
(Aug 16, 2017 09:53 PM)Ninja Wrote:  Because for people beginning in web-botting it is easier.

In life It's easier to kill myself, doesn't mean I'd do it. Same rule applies. You either use good practices or you will fail, horribly.
(Aug 16, 2017 09:54 PM)DeadKube Wrote:  In life It's easier to kill myself

the worst analogy I have ever seen
(Aug 16, 2017 09:56 PM)Ninja Wrote:  the worst analogy I have ever seen

Life is hard! Some people say living life is like spending time in hell. Existance being sorrow. Analogy explained. Now back on topic.
(Aug 16, 2017 08:13 PM)DeadKube Wrote:  Oh thank God at least someone gets it!
You could also look into webbrowser extension development since it would be an excellent project for such a thing. That is if you're making a lastpass alternative.

Why anyone would use a webbrowser control for anything besides making your own 'webbrowser' for learning purposes is beyond me. It uses Internet Explorer for gods sake. Why is that bad, you may ask? To start with IE is incredibly dated, it will not support certain JS functions and will thus result in compatibility issues. Any webdev knows this and any webdev will recommend you to NOT use IE at all. Second, if you're not showing the webbrower control to the user then what exactly is the point even? This control was developed to allow your user to visit a help page for example, or to learn you some basics.

You can make your own webbrowser using built in .net classes or go beyond that. Go deeper. Anyway, please just use the Gecko or webkit. Do yourself a favor.

To log-in all you actually have to do is 'follow the money' so to speak. Look where the information is posted to, and use that service/api. I know all about hidden fields that try and stop this but you can still circumvent this. Lol.
Even captcha's can be mitigated using certain tactics by for example showing the user the captcha and making the user fill it in.. Remember that tokens can be generated by you..

I am seeing the web browser. I also do know the many draw backs of IE, I actually had to update it to Version 11 for this project. I'm new to doing anything with editing/changing html values and elements so it's best for me to visually see what happening and work from a easier point of view. I have tried to use api's; however, I never understood how to use them.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by blackcoder00Jan 30, 2021 10:24 PM 9 257 Jan 30, 2021 10:24 PM
Last Post: saltycracker
[Python] by uzolSep 4, 2020 10:06 PM 4 204 Sep 4, 2020 10:06 PM
Last Post: uzol
[Shell] by rockbottomiswhereiamOct 23, 2019 02:21 PM 1 168 Oct 23, 2019 02:21 PM
Last Post: TyrantKingBen