Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.electronics.design > #409621 > unrolled thread

OT: Virus infection mechanisms

Started byDon Y <blockedofcourse@foo.invalid>
First post2016-04-28 08:51 -0700
Last post2016-05-01 00:29 -0400
Articles 17 — 7 participants

Back to article view | Back to sci.electronics.design


Contents

  OT: Virus infection mechanisms Don Y <blockedofcourse@foo.invalid> - 2016-04-28 08:51 -0700
    Re: OT: Virus infection mechanisms "Teodor V." <teodor-see-signature@invalid.invalid> - 2016-04-28 19:17 +0200
      Re: OT: Virus infection mechanisms Don Y <blockedofcourse@foo.invalid> - 2016-04-28 22:31 -0700
    Re: OT: Virus infection mechanisms Clifford Heath <no.spam@please.net> - 2016-04-29 07:29 +1000
      Re: OT: Virus infection mechanisms Don Y <blockedofcourse@foo.invalid> - 2016-04-28 22:33 -0700
        Re: OT: Virus infection mechanisms Clifford Heath <no.spam@please.net> - 2016-04-29 16:43 +1000
          Re: OT: Virus infection mechanisms Don Y <blockedofcourse@foo.invalid> - 2016-04-29 01:48 -0700
            Re: OT: Virus infection mechanisms Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2016-04-29 12:36 +0200
              Re: OT: Virus infection mechanisms Don Y <blockedofcourse@foo.invalid> - 2016-05-01 10:12 -0700
                Re: OT: Virus infection mechanisms Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2016-05-02 04:38 +0200
                  Re: OT: Virus infection mechanisms Don Y <blockedofcourse@foo.invalid> - 2016-05-01 20:04 -0700
                    Re: OT: Virus infection mechanisms Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2016-05-02 17:59 +0200
                      Re: OT: Virus infection mechanisms Don Y <blockedofcourse@foo.invalid> - 2016-05-02 11:59 -0700
            Re: OT: Virus infection mechanisms Nobody <nobody@nowhere.invalid> - 2016-05-01 04:53 +0100
      Re: OT: Virus infection mechanisms jurb6006@gmail.com - 2016-04-29 05:11 -0700
        Re: OT: Virus infection mechanisms Don Y <blockedofcourse@foo.invalid> - 2016-04-29 19:56 -0700
        Re: OT: Virus infection mechanisms rickman <gnuarm@gmail.com> - 2016-05-01 00:29 -0400

#409621 — OT: Virus infection mechanisms

FromDon Y <blockedofcourse@foo.invalid>
Date2016-04-28 08:51 -0700
SubjectOT: Virus infection mechanisms
Message-ID<nftbc8$8l6$1@dont-email.me>
Sorry, couldn't think of a better forum...

I suspect antivirus tools just check for "characteristic signatures"
in files and, from that, deduce that the file is "infected".  The thinking
being that these combinations of bytes don't appear in "normal" software.

Assuming that to be true:
- how long are these signatures?  i.e., do the tools check for a fixed
   number of bytes in all "programs"?  Or, do they effectively verify the
   presence of the entire viral payload?
- for DLL infections, do they hook DLLmain?  Or, pick some "random" (all?!)
   entry point in the library and "hope for the best" (worst)?

Finally, is it TYPICALLY an exercise in futility to try to remove/"comment
out" the viral load (if it is always an initial stanza, then one should
be able to just "skip past it"; if tightly interwoven in the code, "ain't
gonna happen")?

Pointers to literature?

[toc] | [next] | [standalone]


#409630

From"Teodor V." <teodor-see-signature@invalid.invalid>
Date2016-04-28 19:17 +0200
Message-ID<nftgee$scr$1@dont-email.me>
In reply to#409621
On 2016-04-28 17:51, Don Y wrote:
> Sorry, couldn't think of a better forum...
> 
> I suspect antivirus tools just check for "characteristic signatures"
> in files and, from that, deduce that the file is "infected".  The thinking
> being that these combinations of bytes don't appear in "normal" software.
> 
> Assuming that to be true:
> - how long are these signatures?  i.e., do the tools check for a fixed
>   number of bytes in all "programs"?  Or, do they effectively verify the
>   presence of the entire viral payload?
> - for DLL infections, do they hook DLLmain?  Or, pick some "random" (all?!)
>   entry point in the library and "hope for the best" (worst)?
> 
> Finally, is it TYPICALLY an exercise in futility to try to remove/"comment
> out" the viral load (if it is always an initial stanza, then one should
> be able to just "skip past it"; if tightly interwoven in the code, "ain't
> gonna happen")?
> 
> Pointers to literature?

I don't have pointers to litterature, but I know that some antivirus
software generates hashes (MD5, SHA-1 and others) from known instances
of malware.

Not only from the file itself, but from parts from the file, like
segments for executables, and files contained in executables.

Another method used is heuristic scanning, like if you make a HTML file
which reads https://paypal.com/ up front in a hyperlink, but links you
to http://paypal.really.fishy.domain/, it will cause a trap or at least
warning.

A third method is to look for intentionally misspelled words, like you
remember how the sildenafil spam used v14gra et al permutations to get
past spam filters (which basically are a niche application of the same
technology that is used to scan for malware).

A virus database basically is a collection of signatures (either MD5,
SHA-1 et al as well as scripted heuristics for known instances of
malware which encrypts itself), signed with strong encryption so the
software is less likely to be tricked to recognize a legit program as a
threat.

As to litteature, come to think of it, I think I remember reading some
of this in a document regarding the ClamAV scanning engine, so that
would be a good starting point for your Google-Fu practice :3

/Teo.
-- 
Teodor Väänänen            | Don't meddle in the affairs of wizards,
teostupiditydor@algonet.se | for you are good and crunchy with
Remove stupidity to reply  | ketchup.

[toc] | [prev] | [next] | [standalone]


#409766

FromDon Y <blockedofcourse@foo.invalid>
Date2016-04-28 22:31 -0700
Message-ID<nfurcp$3e6$1@dont-email.me>
In reply to#409630
On 4/28/2016 10:17 AM, Teodor V. wrote:
> I don't have pointers to litterature, but I know that some antivirus
> software generates hashes (MD5, SHA-1 and others) from known instances
> of malware.

Yes, but surely (?) not of the entire file?  I.e., they'd have to store
the hash of foo.exe infected with malware1, foo.exe infected with malware2,
foo.exe infected with malware3... bar.dll infected with malware1, ...

And, would they then treat each such datapoint as a tuple:
    (filename, infection, hash)
Would altering filename then complicate detection by breaking the typle?
Or, just a bunch of (infection, hash) typles expecting the hash space to
be sparse, even in the face of countless possible filenames?

So, prepending "This is not an executable" to a file (making it so it
wouldn't be loadable) would alter the hash of the file -- just as
"Here's something else I want to try" would?  (i.e., chances are, they've
never encountered foo.exe thusly modified!)

> Not only from the file itself, but from parts from the file, like
> segments for executables, and files contained in executables.

So, they have to understand the structure of the file containing the potential
payload -- enough to be able to isolate the "active" part.

A payload in a JPG (that targets a flaw in some particular image viewer)
would be different than in an EXE, etc.?

> Another method used is heuristic scanning, like if you make a HTML file
> which reads https://paypal.com/ up front in a hyperlink, but links you
> to http://paypal.really.fishy.domain/, it will cause a trap or at least
> warning.

Yes, by watching how it behaves when "activated".

> A third method is to look for intentionally misspelled words, like you
> remember how the sildenafil spam used v14gra et al permutations to get
> past spam filters (which basically are a niche application of the same
> technology that is used to scan for malware).
>
> A virus database basically is a collection of signatures (either MD5,
> SHA-1 et al as well as scripted heuristics for known instances of
> malware which encrypts itself), signed with strong encryption so the
> software is less likely to be tricked to recognize a legit program as a
> threat.

<frown>  None of this tells me how to isolate a payload in a particular
file and defeat it (excise that code stanza, replace it with NoOps, etc.)

And, presumably, AV products don't remoe the threat; they remove the
carrier!

> As to litteature, come to think of it, I think I remember reading some
> of this in a document regarding the ClamAV scanning engine, so that
> would be a good starting point for your Google-Fu practice :3

Thanks, I'll have a look.

[toc] | [prev] | [next] | [standalone]


#409706

FromClifford Heath <no.spam@please.net>
Date2016-04-29 07:29 +1000
Message-ID<5722923a$0$44338$c3e8da3$aae71a0a@news.astraweb.com>
In reply to#409621
On 29/04/16 01:51, Don Y wrote:
> I suspect antivirus tools just check for "characteristic signatures"

snip

> Pointers to literature?

You aren't going to find the truth about what commercial virus scanners 
actually do. It's their most highly confidential and valuable trade 
secrets, and is extremely well-defended.

Clifford Heath.

[toc] | [prev] | [next] | [standalone]


#409767

FromDon Y <blockedofcourse@foo.invalid>
Date2016-04-28 22:33 -0700
Message-ID<nfurhf$3e6$2@dont-email.me>
In reply to#409706
On 4/28/2016 2:29 PM, Clifford Heath wrote:
> On 29/04/16 01:51, Don Y wrote:
>> I suspect antivirus tools just check for "characteristic signatures"
>
> snip
>
>> Pointers to literature?
>
> You aren't going to find the truth about what commercial virus scanners
> actually do. It's their most highly confidential and valuable trade secrets,
> and is extremely well-defended.

I'm not interested in how AV scanners work -- except as a tutorial on how *I*
can locate a payload in a particular file.

Obviously, an executable that is a threat to a Windows/x86 box is not likely
to be a threat to a SPARC machine -- even though the SPARC owner might want
to know that the file is "not as it should be".

[toc] | [prev] | [next] | [standalone]


#409772

FromClifford Heath <no.spam@please.net>
Date2016-04-29 16:43 +1000
Message-ID<57231407$0$46649$c3e8da3$e074e489@news.astraweb.com>
In reply to#409767
On 29/04/16 15:33, Don Y wrote:
> On 4/28/2016 2:29 PM, Clifford Heath wrote:
>> On 29/04/16 01:51, Don Y wrote:
>>> I suspect antivirus tools just check for "characteristic signatures"
>> You aren't going to find the truth about what commercial virus scanners
>> actually do. It's their most highly confidential and valuable trade
>> secrets, and is extremely well-defended.
> I'm not interested in how AV scanners work -- except as a tutorial on
> how *I* can locate a payload in a particular file.

There is a number of effective techniques for efficiently scanning for
any of many given bitstrings (of extended lengths), at any offset in a
suspect file. One that I'm aware of uses a "rolling checksum" like an
Adler32; one such checksum for each target bitstring length. So for
fast scanning, normally the dictionary would be normalized to just one
or two lengths, and when the rolling checksum fires (by a match in a
hash table), the full bitstring gets checked at this location.

"rsync" uses a similar mechanism to find likely block matches, which
are then checked by a stronger checksum (MD5, SHA1, etc). We used it
in my related patent as well.

> Obviously, an executable that is a threat to a Windows/x86 box is not
> likely
> to be a threat to a SPARC machine -- even though the SPARC owner might want
> to know that the file is "not as it should be".

There's been an issue with aeroplane cockpits getting infected with
Android malware (that cannot harm the plane) when service folk use
the USB sockets to charge their phones. The infection can be passed
on to other Android devices, which is the actual risk.

Clifford Heath.

[toc] | [prev] | [next] | [standalone]


#409776

FromDon Y <blockedofcourse@foo.invalid>
Date2016-04-29 01:48 -0700
Message-ID<nfv6v0$6f6$1@dont-email.me>
In reply to#409772
On 4/28/2016 11:43 PM, Clifford Heath wrote:
> On 29/04/16 15:33, Don Y wrote:
>> On 4/28/2016 2:29 PM, Clifford Heath wrote:
>>> On 29/04/16 01:51, Don Y wrote:
>>>> I suspect antivirus tools just check for "characteristic signatures"
>>> You aren't going to find the truth about what commercial virus scanners
>>> actually do. It's their most highly confidential and valuable trade
>>> secrets, and is extremely well-defended.
>> I'm not interested in how AV scanners work -- except as a tutorial on
>> how *I* can locate a payload in a particular file.
>
> There is a number of effective techniques for efficiently scanning for
> any of many given bitstrings (of extended lengths), at any offset in a
> suspect file. One that I'm aware of uses a "rolling checksum" like an
> Adler32; one such checksum for each target bitstring length. So for
> fast scanning, normally the dictionary would be normalized to just one
> or two lengths, and when the rolling checksum fires (by a match in a
> hash table), the full bitstring gets checked at this location.

Again, that only tells me how to locate a specific *signature* in a file.
It doesn't tell me how to find the likely location of an infection in a
file and excise the infection from the file (e.g., with a hex editor).

It's easy to see how malware can *deliver* a payload to a system.  But,
if you assume a virus wants to replicate, then it needs a way of attaching
itself to "suitable files" (most obviously executables) in such a way that
the virus doesn't need to understand much about what the file is doing.

For example, prepending itself to an executable so that control transfers
to the malicious code *first*, allowing it to "do whatever"; then chaining
to the original "appended" executable so the user is unaware that anything
unexpected has just happened.

It would, I imagine, be difficult to insert malware at a "random" location
in an executable -- though could imagine "enough smarts" allowing it to
locate startup code and install itself in some portion of the image KNOWING
PARTICULARS ABOUT THE TYPICAL IMAGE FORMAT for that platform.

(I suspect simpler is the safer approach -- for most malware.  Too much
bloat makes an executable "suspicious")

[toc] | [prev] | [next] | [standalone]


#409783

FromHans-Peter Diettrich <DrDiettrich1@aol.com>
Date2016-04-29 12:36 +0200
Message-ID<dogs36F1l35U2@mid.individual.net>
In reply to#409776
Don Y schrieb:

> It would, I imagine, be difficult to insert malware at a "random" location
> in an executable -- though could imagine "enough smarts" allowing it to
> locate startup code and install itself in some portion of the image KNOWING
> PARTICULARS ABOUT THE TYPICAL IMAGE FORMAT for that platform.

PE program files come with verbose names of system calls in their fixup 
tables, so that it's easy to find useful locations in such a file.

DoDi

[toc] | [prev] | [next] | [standalone]


#410110

FromDon Y <blockedofcourse@foo.invalid>
Date2016-05-01 10:12 -0700
Message-ID<ng5d83$7ug$1@dont-email.me>
In reply to#409783
On 4/29/2016 3:36 AM, Hans-Peter Diettrich wrote:
> Don Y schrieb:
>
>> It would, I imagine, be difficult to insert malware at a "random" location
>> in an executable -- though could imagine "enough smarts" allowing it to
>> locate startup code and install itself in some portion of the image KNOWING
>> PARTICULARS ABOUT THE TYPICAL IMAGE FORMAT for that platform.
>
> PE program files come with verbose names of system calls in their fixup tables,
> so that it's easy to find useful locations in such a file.

 From what I've managed to find, it seems like the easiest way is just
to insert a stanza *before*[1] control is transferred to main() that
delivers the payload and then JUMPS to main.

I'll drag out a disassembler and see what sort of "nonsense" it encounters.

[1] Of course, the position of the inserted "code" in the file can actually
be AFTER the end of the original file as this makes it easier to glob onto
an existing file without having to rewrite it in its entirety.  Less effort
required to chase down "where" to inject the patch.

[toc] | [prev] | [next] | [standalone]


#410181

FromHans-Peter Diettrich <DrDiettrich1@aol.com>
Date2016-05-02 04:38 +0200
Message-ID<dont85Fes25U4@mid.individual.net>
In reply to#410110
Don Y schrieb:
> On 4/29/2016 3:36 AM, Hans-Peter Diettrich wrote:

>> PE program files come with verbose names of system calls in their 
>> fixup tables,
>> so that it's easy to find useful locations in such a file.
> 
>  From what I've managed to find, it seems like the easiest way is just
> to insert a stanza *before*[1] control is transferred to main() that
> delivers the payload and then JUMPS to main.

It's easy to change the program entry point to somewhere in appended 
code, but a start address near the end of the code segment is quite easy 
to detect. The viral code then also cannot access anything that is 
initiated in the startup code, like memory management and standard 
handles. The code also will have to call OS routines for connecting to 
the outer world, which may deserve some setup before they can be used.

> I'll drag out a disassembler and see what sort of "nonsense" it encounters.

Right, that would be nice to know.

> [1] Of course, the position of the inserted "code" in the file can actually
> be AFTER the end of the original file as this makes it easier to glob onto
> an existing file without having to rewrite it in its entirety.  Less effort
> required to chase down "where" to inject the patch.

Right.

DoDi

[toc] | [prev] | [next] | [standalone]


#410184

FromDon Y <blockedofcourse@foo.invalid>
Date2016-05-01 20:04 -0700
Message-ID<ng6fum$p7t$1@dont-email.me>
In reply to#410181
On 5/1/2016 7:38 PM, Hans-Peter Diettrich wrote:
> Don Y schrieb:
>> On 4/29/2016 3:36 AM, Hans-Peter Diettrich wrote:
>
>>> PE program files come with verbose names of system calls in their fixup tables,
>>> so that it's easy to find useful locations in such a file.
>>
>>  From what I've managed to find, it seems like the easiest way is just
>> to insert a stanza *before*[1] control is transferred to main() that
>> delivers the payload and then JUMPS to main.
>
> It's easy to change the program entry point to somewhere in appended code, but
> a start address near the end of the code segment is quite easy to detect. The
> viral code then also cannot access anything that is initiated in the startup
> code, like memory management and standard handles. The code also will have to
> call OS routines for connecting to the outer world, which may deserve some
> setup before they can be used.

I was thinking of it the other way around:  payload installs itself (without
relying on ANYTHING in the infected executable), then just "falls into" the
intended application.

>> I'll drag out a disassembler and see what sort of "nonsense" it encounters.
>
> Right, that would be nice to know.

What I am after is a confirmation that the viral load wraps *around* the
original application instead of threading itself THROUGHOUT it.  The former
has some chance of being removed.  The latter would be a lost cause
(how do you recognize the added infection from the original application?)

Largely an educational experience as I can live without the application
entirely (so, it's more of a "challenge")

>> [1] Of course, the position of the inserted "code" in the file can actually
>> be AFTER the end of the original file as this makes it easier to glob onto
>> an existing file without having to rewrite it in its entirety.  Less effort
>> required to chase down "where" to inject the patch.
>
> Right.

[toc] | [prev] | [next] | [standalone]


#410237

FromHans-Peter Diettrich <DrDiettrich1@aol.com>
Date2016-05-02 17:59 +0200
Message-ID<dopcs5Foa1hU2@mid.individual.net>
In reply to#410184
Don Y schrieb:

> I was thinking of it the other way around:  payload installs itself 
> (without
> relying on ANYTHING in the infected executable), then just "falls into" the
> intended application.

Such a malware could not do much, without a noticeable delay of the 
program start. For replication it has to scan other infectable 
executables. For sending passwords it has to scan related places in the 
OS, then send mail or transfer them otherwise to its remote server. Such 
calls may be what AV software is after.

DoDi

[toc] | [prev] | [next] | [standalone]


#410261

FromDon Y <blockedofcourse@foo.invalid>
Date2016-05-02 11:59 -0700
Message-ID<ng87sl$r7q$1@dont-email.me>
In reply to#410237
On 5/2/2016 8:59 AM, Hans-Peter Diettrich wrote:
> Don Y schrieb:
>
>> I was thinking of it the other way around:  payload installs itself (without
>> relying on ANYTHING in the infected executable), then just "falls into" the
>> intended application.
>
> Such a malware could not do much, without a noticeable delay of the program
> start.

Sure it could!  It can fork(2) just after loading it's initial payload
and let the real application load alongside it.  Then, act as yet another
process running on the host.

Or, copy itself onto persisitent media as a named file and install an
entry in the registry to ensure it starts up on next boot (etc.)

> For replication it has to scan other infectable executables. For sending
> passwords it has to scan related places in the OS, then send mail or transfer
> them otherwise to its remote server. Such calls may be what AV software is after.

That all falls under the umbrella of behavioral analysis.  I.e., who cares
what the ACTUAL bit pattern of the "infection" happens to be; you're really
more concerned with what it tries to *DO*!  An unwanted payload could sit
and harmlessly burn CPU cycles.  While this may be annoying, it's not exposing
you to a material loss (data, information, etc.).

[toc] | [prev] | [next] | [standalone]


#410076

FromNobody <nobody@nowhere.invalid>
Date2016-05-01 04:53 +0100
Message-ID<pan.2016.05.01.03.54.43.214000@nowhere.invalid>
In reply to#409776
On Fri, 29 Apr 2016 01:48:43 -0700, Don Y wrote:

> It's easy to see how malware can *deliver* a payload to a system.  But, if
> you assume a virus wants to replicate, then it needs a way of attaching
> itself to "suitable files" (most obviously executables) in such a way that
> the virus doesn't need to understand much about what the file is doing.

Viruses which spread by infecting arbitrary files in the hope that such a
file will eventually be copied to another system are fairly uncommon
nowadays. They have largely been replaced by either

a) worms, which typically infect a specific subsystem (usually related to
some form of communication channel), then use that to spread to other
systems, or

b) simple malware spread using a top-down approach; compromised systems
are used to hijack web or email servers which will then distribute malware
to PCs, smartphones etc. Each particular type of malware typically
distributes a different type of malware to a different type of
system, rather than self-replicating.

Infection doesn't generally attempt to "splice" code into arbitrary
executables or DLLs, but either replaces standard executables (or DLLs,
etc) with an infected version or installs entirely new files which are
then activated by modifying the registry or other configuration
mechanisms.

The malicious file may have some degree of polymorphism in order to
frustrate detection, but this is unlikely to take the form of merging with
a pre-existing version of the file. Rather, any such file will be
generated from a "template" which includes specific mechanisms for
polymorphism.

[toc] | [prev] | [next] | [standalone]


#409788

Fromjurb6006@gmail.com
Date2016-04-29 05:11 -0700
Message-ID<60a33f07-ad08-4137-bae9-38d17376d5aa@googlegroups.com>
In reply to#409706
>"You aren't going to find the truth about what commercial virus >scanners
>actually do. It's their most highly confidential and valuable trade
>secrets, and is extremely well-defended. "

I think they're hiding more than that. I'll l eave it at this :

Who are the only ones who profit from the propagation of a virus ? 

The only ones. 

[toc] | [prev] | [next] | [standalone]


#409946

FromDon Y <blockedofcourse@foo.invalid>
Date2016-04-29 19:56 -0700
Message-ID<ng16m4$d3m$1@dont-email.me>
In reply to#409788
On 4/29/2016 5:11 AM, jurb6006@gmail.com wrote:
>> "You aren't going to find the truth about what commercial virus >scanners
>> actually do. It's their most highly confidential and valuable trade
>> secrets, and is extremely well-defended. "
>
> I think they're hiding more than that. I'll l eave it at this :
>
> Who are the only ones who profit from the propagation of a virus ?

The folks who implement ransomware?
The folks who harvest passwords and account names?

> The only ones.

[toc] | [prev] | [next] | [standalone]


#410077

Fromrickman <gnuarm@gmail.com>
Date2016-05-01 00:29 -0400
Message-ID<ng40he$meg$1@dont-email.me>
In reply to#409788
On 4/29/2016 8:11 AM, jurb6006@gmail.com wrote:
>> "You aren't going to find the truth about what commercial virus >scanners
>> actually do. It's their most highly confidential and valuable trade
>> secrets, and is extremely well-defended. "
>
> I think they're hiding more than that. I'll l eave it at this :
>
> Who are the only ones who profit from the propagation of a virus ?
>
> The only ones.

And who are the ones who profit from criminal behavior?  The legal 
system!  There are obvious (but wrong) conclusions in both cases.

-- 

Rick C

[toc] | [prev] | [standalone]


Back to top | Article view | sci.electronics.design


csiph-web