Help With Obtaining An IP Address

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Help With Obtaining An IP Address

Post by CyberCitizen » Sun Oct 30, 2005 2:35 pm

Hey Guys,

I Need Some Help With Obtaining A Users IP Address. The User Will Upload A File Via A Dialog Box, However I Need To Log The User IP Address With The File.

Here Is My Script.


HTTPRequest>http://checkip.dyndns.org/,,GET,,HTMLResponse
MessageModal>%HTMLResponse%


Is There Anyway I Can Just Return The IP Address.

I Was Thinking Of Sub>14 Spaces However That Only Works With Numbers.

Any Help You Could Provide Would Be Great.
FIREFIGHTER

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Sun Oct 30, 2005 2:48 pm

Never Mind I Worked Out The Script.


//Users IP Address
HTTPRequest>http://checkip.dyndns.org/,,GET,,HTMLResponse
Position>Current IP Address: ,%HTMLResponse%,1,StartPos
Let>%StartPos%=%StartPos%+20
MidStr>%HTMLResponse%,57,13,IPAddress
MessageModal>%IPAddress%


If Anyone Else Has A Neater Idea Let Me Know But At This Stage Its Working.
FIREFIGHTER

User avatar
Monkster
Junior Coder
Posts: 42
Joined: Fri Oct 04, 2002 9:37 pm
Location: On an Island with Wilson

Post by Monkster » Sun Oct 30, 2005 3:33 pm

CyberCitizen wrote:Never Mind I Worked Out The Script.

If Anyone Else Has A Neater Idea Let Me Know But At This Stage Its Working.
Hi CyberCitizen:

Thanks for the link to dyndns ip page, I've used their free services in the past but never noticed that page.

I've been meaning to ask you if you have title case script (because I notice you post in title case) - if you do would you mind please posting it?

Thanks!
Best Wishes,
Monkster

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Sun Oct 30, 2005 4:20 pm

Ha Ha Monkster,

Sorry No Script There. Thats Just How I Have Typed For A While.

Worked With Alot Of Addresses So Everything Became Second Nature When Typing.

I Also Have A Bug in My Script.

The Script Works Fine If The IP Address Is 123.12.12.123 But It The IP Address Is Longer Or Shorter It Will Not Work.

I Have Been Playing Around With A Few New Ideas But Still Cant Seem To Get It Working.


//Users IP Address
HTTPRequest>http://checkip.dyndns.org/,,GET,,HTMLResponse
Position>Current IP Address: ,%HTMLResponse%,1,StartPos
Position>,%HTMLResponse%,1,EndPos
Let>%StartPos%=%StartPos%+20
Let>%EndPos%=%EndPos%-14
Len>%HTMLResponse%,SourceLength
Let>FinishLen=%SourceLength%-%EndPos%
MidStr>%HTMLResponse%,%StartPos%,%FinishLen%,IPAddress
MessageModal>%IPAddress%


Please Help!
FIREFIGHTER

User avatar
Monkster
Junior Coder
Posts: 42
Joined: Fri Oct 04, 2002 9:37 pm
Location: On an Island with Wilson

Post by Monkster » Sun Oct 30, 2005 4:20 pm

Does this look ok?

//Users IP Address
HTTPRequest>http://checkip.dyndns.org/,,GET,,HTMLResponse
Position>Current IP Address: ,%HTMLResponse%,1,StartPos
Let>%StartPos%=%StartPos%+20
MidStr>%HTMLResponse%,57,15,IPAddress
StringReplace>%IPAddress%,%IPAddress%, ,,IPAddress
MessageModal>%IPAddress%
Best Wishes,
Monkster

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Mon Oct 31, 2005 7:20 am

Hey Monkster,

Thanks For The Script It Kind Of Work's However Still Not Quite What I Need.

I Need It To Stop At The End Of The IP Address, The Script You Posted Includes The Extra Information At The End Of The Source.

This Is What %HTMLResponse% Returns. What I Am Trying To Obtain Is The IP Address Only. I Have Been Able To Get The Starting Position Ok, However I Can't Get It To Stop At The End Of The IP Address Or Forget The Last Part Of The %HTMLResponse%


Current IP CheckCurrent IP Address: 210.11.52.185


Please Help, This Is Starting To Get A Little Urgent Now. Thats For Your Help By The Way.
FIREFIGHTER

User avatar
Monkster
Junior Coder
Posts: 42
Joined: Fri Oct 04, 2002 9:37 pm
Location: On an Island with Wilson

Post by Monkster » Mon Oct 31, 2005 9:10 am

Hi CyberCitizen,

Sorry about that, my last post was way off, don't know what happened it worked at the time. I must have pasted some interim code.

This is not pretty but it will work. The longest that the IP could be is 15 characters and it starts at position 77 so I think this will work. I am not sure what the lowest string length of an IP is so uncomment as needed.


//Users IP Address
HTTPRequest>http://checkip.dyndns.org/,,GET,,HTMLResponse
MidStr>%HTMLResponse%,77,15,IPAddress
StringReplace>%IPAddress%,/,,IPAddress
StringReplace>%IPAddress%,%IPAddress%, ,,IPAddress
StringReplace>%IPAddress%,b,,IPAddress
StringReplace>%IPAddress%,o,,IPAddress

//StringReplace>%IPAddress%,d,,IPAddress
//StringReplace>%IPAddress%,y,,IPAddress
//StringReplace>%IPAddress%,>,,IPAddress
//StringReplace>%IPAddress%,h,,IPAddress
//StringReplace>%IPAddress%,t,,IPAddress
//StringReplace>%IPAddress%,m,,IPAddress
//StringReplace>%IPAddress%,l,,IPAddress

MessageModal>%IPAddress%
Best Wishes,
Monkster

IanSmith
Junior Coder
Posts: 24
Joined: Tue Jul 12, 2005 2:31 pm

Post by IanSmith » Mon Oct 31, 2005 4:22 pm

This is off the top of my head, so it might need some checking:

pos>,%HTMLResponse%,77,IPend
let>iplength=%IPend%-77
MidStr>%HTMLResponse%,77,%iplength%,IPAddress

You might have to add one or two to the variables, but it should be close.

Hope that helps,

Ian

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Mon Oct 31, 2005 5:37 pm

My two cents worth:

You just need to write an old-fashioned filter to only include the valid characters in the IP address.

Of course, use a POS> to find the start of the IP address, then just read character by character to the end of the IP. Here is an example of a filter I use to strip out the order qty from a text file.

rem> find the order qty
let>qtyStart=dollarSign-6
let>Digit=0
REM> As valid characters are found,they are 'stuffed' into this string
let>OrdQty=
rem> determine a string that will be your RAW data string (trash and all)
midstr>%OrderText%,%qtyStart%,6,RawQty
len>%RawQty%,lengthOrdQty
Label>QtyDigit
rem> increment the digit counter
let>Digit=Digit+1
rem> pull out a single digit from the string to be tested
Midstr>%RawQty%,%Digit%,1,DigitResult
rem> Try to locate the current digit within the Valid string
Pos>%DigitResult%,%ValidNbr%,1,Found
if>%Found%>0
Concat>OrdQty,DigitResult
endif>
rem> if you have not reached the end of the string, then continue checking
if>%Digit%QtyDigit
endif>

The result will be that once the end is reached, the OrdQty variable will only hold characters which are in my "Valid" list.

your valid list would be LET>ValidIP=0123456789.

clear as mud?

I know reading someone else's code is never very easy.

Ask and I can clarify it.

SkunkWorks

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Mon Oct 31, 2005 10:53 pm

Hey Monkster,

Thanks For Your Script That Seemed To Have Worked. I Had To Add A Small Adjustment But So Far Everything Looks Good.

This Is What The Script Was For.

Program: http://cybercitizen.egn.com.au/EGN%20De ... loader.exe
Where The File Is Uploaded: http://cybercitizen.egn.com.au/hacker_demos
FIREFIGHTER

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts