flat assembler
Message board for the users of flat assembler.

Index > Windows > dotted IP address string

Author
Thread Post new topic Reply to topic
anon



Joined: 31 Dec 2008
Posts: 2
anon
hi
I got ip string like here
Code:
ip db '72.14.205.100',0    

how to add 1 or 10 or 1000?
thanks.
Post 31 Dec 2008, 11:54
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17255
Location: In your JS exploiting you and your system
revolution
Where do you want to add your number? Just to one of the octets or to the whole number? You can convert it to a 32bit binary number first and then add whatever you please with the add instruction.
Post 31 Dec 2008, 12:17
View user's profile Send private message Visit poster's website Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel
1. Use the inet_addr API to convert the IP address to an integer. Use bit rotation instructions to convert back and forth between host/network byte orders (ntohl and htonl APIs do that too), and add/inc to modify any of the four parts.

or

2. Manually parse the IP address string, convert the parts to decimal and modify accordingly.
Post 31 Dec 2008, 15:00
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
Here's a solution of doing that, hope it helps.

Code:
        invoke inet_addr, ip                  ; dot notation string to network bytes
        invoke ntohl, eax                     ; from tcp/ip network order to host byte order
        inc eax                               ; add 1
        invoke htonl, eax                     ; from host to tcp/ip network bytes
        invoke inet_ntoa, eax                 ; network bytes to dot notation string
        invoke lstrcpy, ip, eax               ; save back to buffer, mind the extra space you might need

        ;ip = '72.14.205.101',0    
Post 31 Dec 2008, 21:23
View user's profile Send private message Reply with quote
anon



Joined: 31 Dec 2008
Posts: 2
anon
hi
I have to read more about APIs functions. Merry Christmas all.
Post 02 Jan 2009, 08:51
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.