Get IP address for form.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
nouse4anick
Forum Newbie
Posts: 6
Joined: Wed Mar 07, 2007 4:07 pm

Get IP address for form.

Post by nouse4anick »

Here is what I have in a web page on my computer:

Code: Select all

<form method="post" action="https://www.wlan.wwu.edu/login.pl" enctype="application/x-www-form-urlencoded" name="bluesocket_u" class="nospace">
<input name="_FORM_SUBMIT" value="1" type="hidden">
<input name="which_form" value="reg" type="hidden">
<input name="destination" value="http://www.google.com/?" type="hidden">
<input name="source" value="140.160.131.111" type="hidden">
<input name="error" value="" type="hidden">
.........
what I need is some bit of code to grab the current ip address from my computer, and replace the 'source' value. I checked javascript and it didn't have what i needed. The CGI code that I found had to be run on the server, the php and perl code also appeared to be server side.

in short what i'm looking for is something like this:

Code: Select all

<form method="post" action="https://www.wlan.wwu.edu/login.pl" enctype="application/x-www-form-urlencoded" name="bluesocket_u" class="nospace">
<input name="_FORM_SUBMIT" value="1" type="hidden">
<input name="which_form" value="reg" type="hidden">
<input name="destination" value="http://www.google.com/?" type="hidden">
<------ some code here that will grab the ip address of my wifi card then print it out formated like this; ----->
<input name="source" value="xxx.xxx.xxx.xxx" type="hidden">
<input name="error" value="" type="hidden">
....
Thanks for any help you guys can give me!
Art
:bow:
Last edited by nouse4anick on Thu Mar 08, 2007 1:20 pm, edited 1 time in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Is that even possible? And you want this to be done in a browser?
nouse4anick
Forum Newbie
Posts: 6
Joined: Wed Mar 07, 2007 4:07 pm

Post by nouse4anick »

Everah wrote:Is that even possible? And you want this to be done in a browser?
should be, it should be able to be done with any inline scripting language.

the only other option is to code the output of the post by hand and make a c or python program that gets the ip addy, inserts it, and then transmits it. but why do that when most of it is done for me in the browser?
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

So you are saying that it can be done, but you dont know how to do it.

Well if you dont know how to do it, how on earth are you so confident that it can be done?
nouse4anick
Forum Newbie
Posts: 6
Joined: Wed Mar 07, 2007 4:07 pm

Post by nouse4anick »

mikeq wrote:So you are saying that it can be done, but you dont know how to do it.

Well if you dont know how to do it, how on earth are you so confident that it can be done?
Considering python, c, java, php, and perl all have functions to return ip addresses, I'm pretty sure what I'm asking for is not impossible. What I am unsure of is how to embed one of those functions into a html file for client side execution.

Now, it might be easier to do a bit of fancy coding and send the data from the post to the intended site addy, in which case any sites that have such info is always welcome. But I'll take just about anything I can get right now.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

In Javascript, it's impossible.
nouse4anick
Forum Newbie
Posts: 6
Joined: Wed Mar 07, 2007 4:07 pm

Post by nouse4anick »

feyd wrote:In Javascript, it's impossible.
notice I didn't include that in my list =b
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

There are no other client-side scripting languages that can come close to being guaranteed there.
nouse4anick
Forum Newbie
Posts: 6
Joined: Wed Mar 07, 2007 4:07 pm

Post by nouse4anick »

feyd wrote:There are no other client-side scripting languages that can come close to being guaranteed there.
then do you have a suggestion as to how I can encode the data packet to make it look like it was submitted by a web browser?
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

What are you aiming to accomplish.


Us knowing what you want to do may help us determine if there are any other ways of accomplishing the same task.
nouse4anick
Forum Newbie
Posts: 6
Joined: Wed Mar 07, 2007 4:07 pm

Post by nouse4anick »

nickvd wrote:What are you aiming to accomplish.


Us knowing what you want to do may help us determine if there are any other ways of accomplishing the same task.
The above markup is basically ripped from a login page for my school's wifi network. What I want to have happen is when my laptop gets it's ip addy from the network at school, it automatically sends the the post message with the current ip addy to log me in to the network.

I see 3 ways to accomplish this: write a small program that outputs the html page with the code and execute the file (open it in fire fox), write client side code in the html file to grab and print the ip address, or write a program that builds the string and sends it to the address...

So thats what I'm trying to do. If anyone has a webpage for making the output string of the post option and sending it please post it, or on how to grab the ip addy client side, please post it.
Post Reply