The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: sasurfman on April 05, 2008, 05:52:22 AM

Title: Trojan horse
Post by: sasurfman on April 05, 2008, 05:52:22 AM
So, I assembled and linked the very first do nothing program in Iczelion's tutorial 2 and then ran the exe.  AVG Free fired off on it and reported Trojan horse Back Door.Poison Ivy.N. Here is the whole program:

.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
.data
.code
start:
invoke  ExitProcess,0
end start

I scanned the \masm32 directory and got no hits with avg.  I also scanned every copy of kernel32.dll (4) and got no hits with avg, so why am I getting a hit on the assembled exe?  Needless to say, this doesn't give me a warm fuzzy.
Title: Re: Trojan horse
Post by: MichaelW on April 05, 2008, 06:01:38 AM
If your system is not otherwise infected, I would say that you are getting a false positive.
Title: Re: Trojan horse
Post by: sasurfman on April 05, 2008, 06:18:41 AM
In the tutorial, Iczelion says his file size of the exe is 1,536 bytes.  My file size is 12,288 bytes.  Quite a bit of difference there.
Title: Re: Trojan horse
Post by: MichaelW on April 05, 2008, 06:32:51 AM
On my system the exe, built with the included batch file, is 2560 bytes. How did you build yours?
Title: Re: Trojan horse
Post by: hutch-- on April 05, 2008, 06:41:47 AM
Builds directly from the masm32 editor at 2k.

Make sure your own system is not infected with a virus but it sounds like a false positive, something that the trashy end of AV scanners do regularly.


    .386
    .model flat, stdcall
    option casemap:none

    include \masm32\include\windows.inc
    include \masm32\include\kernel32.inc
    includelib \masm32\lib\kernel32.lib

    .data

    .code

    start:
    invoke  ExitProcess,0

    end start
Title: Re: Trojan horse
Post by: sinsi on April 05, 2008, 06:50:40 AM
heh, I just built Hutch's code and AVG gave me the same trojan warning, and I damned well know that it ain't. Them's the breaks...
Title: Re: Trojan horse
Post by: sasurfman on April 05, 2008, 07:22:50 AM
I built mine just as the tutorial stated. 
ml /c /coff /Cp msgbox.asm
link /subsystem:windows /libpath:c:\masm32\lib msgbox.obj

I'm running xp home on this laptop.

I might add that I went on to the next listing and added the code to show the message box.  After assembling and linking AVG did not fire on this version.  The exe is 16 KB.
Title: Re: Trojan horse
Post by: jj2007 on April 05, 2008, 07:29:29 AM
If your file size is well above the expected value, then it's not a false positive. Try to disassemble the exe...
Title: Re: Trojan horse
Post by: sinsi on April 05, 2008, 08:06:18 AM
Replacing "invoke ExitProcess,0" with "ret" (exe is 1024 bytes) passes AVG's test.

I think it has to do with the number of imports...there are quite a few posts here about false positives.
Title: Re: Trojan horse
Post by: jj2007 on April 05, 2008, 08:48:41 AM
It is difficult to bloat an "invoke ExitProcess, 0" to the extra 10k that he produced. Disassemble the exe, and I am sure there will be nice surprises.
Title: Re: Trojan horse
Post by: sasurfman on April 05, 2008, 08:49:56 AM
I found the problem with the file size.  I was using link ver 6.00.8447.  When I used link ver 5.12.8078 the file size came down to 2,560 bytes for the version that outputs a messagebox. I don't know why link ver 6.00.8447 increases the file size, but it does. I have VC 6++ installed on this pc.
Title: Re: Trojan horse
Post by: jj2007 on April 05, 2008, 08:56:36 AM
Still, a linker that produces 10k extra and a virus warning might have a little problem.
Title: Re: Trojan horse
Post by: hutch-- on April 05, 2008, 09:00:51 AM
If you want to keep using the VC6 linker, set the file alignment to 512 bytes.
Title: Re: Trojan horse
Post by: sasurfman on April 05, 2008, 09:18:40 AM
Quote from: hutch-- on April 05, 2008, 09:00:51 AM
If you want to keep using the VC6 linker, set the file alignment to 512 bytes.

Will that resolve the file size difference?  I'm not how to set the alignment, but I think the directive is: .align page
Is that correct?
Title: Re: Trojan horse
Post by: hutch-- on April 05, 2008, 09:41:58 AM
link /?
Title: Re: Trojan horse
Post by: sasurfman on April 05, 2008, 09:58:08 AM
Quote from: hutch-- on April 05, 2008, 09:41:58 AM
link /?

That worked. File size 2,560 bytes.  Thank you.

I suppose I can safely ignore the "Link: warning LNK4108: /Align specified without /driver or /vxd; image may not run" message.
Title: Re: Trojan horse
Post by: jj2007 on April 05, 2008, 12:13:04 PM
You can safely ignore the warning if you don't intend to write a commercial app for future Windows versions. Although they'll probably never tighten the rules... /align:64 works perfectly on my XP box, with 768 bytes ;-)
Title: Re: Trojan horse
Post by: hutch-- on April 05, 2008, 12:25:47 PM
Interestingly enough they learnt the lesson with the later linkers which will all do 512 byte alignment. Its part of the PE spec so it runs on all versions of 32 bit Windows.
Title: Re: Trojan horse
Post by: jj2007 on April 05, 2008, 01:20:11 PM
This is not part of the PE specs but still runs smoothly on XP... 704 bytes

.386
    .model flat, stdcall
    .nolist
    option casemap:none

    include \masm32\include\windows.inc
    include \masm32\include\kernel32.inc
    includelib \masm32\lib\kernel32.lib
    include \masm32\include\user32.inc
    includelib \masm32\lib\user32.lib

.code
tx db "Wow", 0
msgtitle db "Align:4", 0

start:
invoke MessageBox, 0, addr tx, addr msgtitle, MB_OK
invoke  ExitProcess,0
end start