flat assembler
Message board for the users of flat assembler.

Index > Windows > [SOLVED] It has to be somewhere above

Author
Thread Post new topic Reply to topic
Picnic



Joined: 05 May 2007
Posts: 1391
Location: Piraeus, Greece
Picnic 05 Mar 2009, 23:39
Hi guys,
I'm having a problem and i need some help, i'm using CRT.DLL
When it goes to this line here
Code:
 cinvoke printf, <'IP: [%s]'>, sip    
it prints my lan ip 192.168.1.10
But if i add some spaces like here
Code:
cinvoke printf, <'IP: [%s]             '>, sip    
i'm getting a message: ACCESS DENIED
I can't locate my error, help.

Code:
        format pe console 4.0

        include 'win32ax.inc'

        NL equ 13,10

        INADDR_ANY      =   0
        IPPROTO_TCP    =   6

        macro err n { mov [env], err#n }

.data
        wsadata         WSADATA
        saddr        sockaddr_in

        argc                 dd      0
        argv               dd      ?
        env                dd      ?
        port               dd      ?
        hsock              dd      ?
        sip                rb      256

.code
main:
        cinvoke __GetMainArgs, argc, argv, env, 0
        cmp [argc], 2
        err 10
        jb DispErr
        mov esi, [argv]
        mov esi, dword [esi+4]
        xor eax,eax
        mov ecx, 4
        err 20
        @@:
        movzx ebx, byte [esi]
        test ebx, ebx
        je @F
        cmp ebx, '0'
        jc DispErr
        cmp ebx, ':'
        jnc DispErr
        lea eax, [eax*5]
        lea eax, [eax*2+ebx-'0']
        inc esi
        loop @b
        @@:
        mov [port], eax
        err 30
        invoke WSAStartup, 0202h, wsadata
        test eax, eax
        jne DispErr
        err 40
        invoke socket, AF_INET, SOCK_STREAM, IPPROTO_TCP
        cmp eax, -1
        je WSAErr
        mov [hsock], eax
        mov [saddr.sin_family], AF_INET
        invoke htons, [port]
        mov [saddr.sin_port], ax
        mov [saddr.sin_addr], INADDR_ANY
        err 50
        invoke bind, [hsock], saddr, sizeof.sockaddr
        cmp eax, -1
        je MainErr
        err 60
        invoke gethostname, sip, 256
        cmp eax, -1
        je MainErr
        err 70
        invoke gethostbyname, eax
        cmp eax, -1
        je MainErr
        mov eax, [eax+12]
        mov eax, [eax]
        mov eax, [eax]
        invoke inet_ntoa, eax
        invoke lstrcpy, sip, eax
        cinvoke printf, <'IP: [%s]'>, sip                      ; <--


         ;
         ;
         ;
         ;

 invoke closesocket, [hsock]
 invoke WSACleanup
   jmp Exit



MainErr:
        invoke closesocket, [hsock]
WSAErr:
        invoke WSACleanup
DispErr:
       cinvoke printf, [env]
Exit:  invoke ExitProcess, 0

.end main



err10 db NL,' usage: SERVER [port]',NL,0
err20 db NL,'Port number failed.',NL,0
err30 db NL,'WSAStartup failed.',NL,0
err40 db NL,'Error at socket()',NL,0
err50 db NL,'Error at bind()',NL,0
err60 db NL,'Error at gethostname()',NL,0
err70 db NL,'Error at gethostbyname()',NL,0
    


Last edited by Picnic on 06 Mar 2009, 21:31; edited 1 time in total
Post 05 Mar 2009, 23:39
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 05 Mar 2009, 23:43
I can't compile this, its saying __GetMainArgs is an undefined symbol
Post 05 Mar 2009, 23:43
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1391
Location: Piraeus, Greece
Picnic 05 Mar 2009, 23:55
Hi comrade,
That's because i'm including the CRTDLL.INC in win32ax.inc
I found it somewhere inside forum, and using it for a long time with no problems so far.


Description:
Download
Filename: CRTDLL.INC
Filesize: 14.89 KB
Downloaded: 338 Time(s)



Last edited by Picnic on 05 Mar 2009, 23:57; edited 1 time in total
Post 05 Mar 2009, 23:55
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20361
Location: In your JS exploiting you and your system
revolution 05 Mar 2009, 23:57
Where is your 'printf' function? The code doesn't compile for me.
Post 05 Mar 2009, 23:57
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1391
Location: Piraeus, Greece
Picnic 06 Mar 2009, 00:07
Also inside CRTDLL revolution.
Post 06 Mar 2009, 00:07
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 06 Mar 2009, 00:25
I'm always getting port number failed. How is it supposed to be used?

This is the code I'm using:
Code:
       format pe console 4.0
       entry main

        include 'win32ax.inc'

        NL equ 13,10

        INADDR_ANY      =   0
        IPPROTO_TCP     =   6

        macro err n { mov [env], err#n }

.data
        wsadata         WSADATA
        saddr           sockaddr_in

        argc            dd      0
        argv            dd      ?
        env             dd      ?
        port            dd      ?
        hsock           dd      ?
        sip             rb      256

.code
main:
        cinvoke __GetMainArgs, argc, argv, env, 0
        cmp [argc], 2
        err 10
        jb DispErr
        mov esi, [argv]
        mov esi, dword [esi+4]
        xor eax,eax
        mov ecx, 4
        err 20
        @@:
        movzx ebx, byte [esi]
        test ebx, ebx
        je @F
        cmp ebx, '0'
        jc DispErr
        cmp ebx, ':'
        jnc DispErr
        lea eax, [eax*5]
        lea eax, [eax*2+ebx-'0']
        inc esi
        loop @b
        @@:
        mov [port], eax
        err 30
        invoke WSAStartup, 0202h, wsadata
        test eax, eax
        jne DispErr
        err 40
        invoke socket, AF_INET, SOCK_STREAM, IPPROTO_TCP
        cmp eax, -1
        je WSAErr
        mov [hsock], eax
        mov [saddr.sin_family], AF_INET
        invoke htons, [port]
        mov [saddr.sin_port], ax
        mov [saddr.sin_addr], INADDR_ANY
        err 50
        invoke bind, [hsock], saddr, sizeof.sockaddr
        cmp eax, -1
        je MainErr
        err 60
        invoke gethostname, sip, 256
        cmp eax, -1
        je MainErr
        err 70
        invoke gethostbyname, eax
        cmp eax, -1
        je MainErr
        mov eax, [eax+12]
        mov eax, [eax]
        mov eax, [eax]
        invoke inet_ntoa, eax
        invoke lstrcpy, sip, eax
        cinvoke printf, <'IP: [%s]'>, sip                      ; <--


         ;
         ;
         ;
         ;

        invoke closesocket, [hsock]
        invoke WSACleanup
        jmp Exit



MainErr:
        invoke closesocket, [hsock]
WSAErr:
        invoke WSACleanup
DispErr:
       cinvoke printf, [env]
Exit:  invoke ExitProcess, 0

err10 db NL,' usage: SERVER [port]',NL,0
err20 db NL,'Port number failed.',NL,0
err30 db NL,'WSAStartup failed.',NL,0
err40 db NL,'Error at socket()',NL,0
err50 db NL,'Error at bind()',NL,0
err60 db NL,'Error at gethostname()',NL,0
err70 db NL,'Error at gethostbyname()',NL,0

section '.idata' import data readable writeable

 library kernel32,'KERNEL32.DLL',\
         wsock32,'WSOCK32.DLL',\
         crtdll,'CRTDLL.DLL'


 include 'api/kernel32.inc'
 include 'api/wsock32.inc'
 include 'crtdll.inc'    
Post 06 Mar 2009, 00:25
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 06 Mar 2009, 00:32
It works for me and I don't seem to be getting ACCESS DENIED anywhere. I can't even see how that can possibly be printed from anywhere.

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 06 Mar 2009, 00:32
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1391
Location: Piraeus, Greece
Picnic 06 Mar 2009, 08:54
comrade wrote:
I can't even see how that can possibly be printed from anywhere.
Good Morning,
Same here comrade, i am getting a system error message and i can't figure out why.
Maybe something bad is going on my desktop pc because i run the code on my laptop and works Mad
Post 06 Mar 2009, 08:54
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 06 Mar 2009, 09:12
Access denied when you run it or compile it? Does the problem reproduce itself consistently?
Post 06 Mar 2009, 09:12
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1391
Location: Piraeus, Greece
Picnic 06 Mar 2009, 09:20
Compiles fine, when i run it from command line, it displays a message in Greek 'Δεν επιτρέπεται η πρόσβαση' translated simply means 'Access Denied'
Post 06 Mar 2009, 09:20
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1391
Location: Piraeus, Greece
Picnic 06 Mar 2009, 21:31
I think i finally found the cause. It was AVG antivirus. I'm so f... pissed off Mad
Thank you all.
Post 06 Mar 2009, 21:31
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 09 Mar 2009, 00:40
Antiviruses are very dumb when it comes to heuristics, esp. assembly apps.
Post 09 Mar 2009, 00:40
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20361
Location: In your JS exploiting you and your system
revolution 09 Mar 2009, 00:52
The most frustrating of all was when I had one of my TEXT (asm source) files tagged by Norton as malware and it refused to let me open it for editing! I had to ask the PC owner to turn off Norton. The owner was quite amused by it when he saw the source file was harmless text. I hate AVs.
Post 09 Mar 2009, 00:52
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.