Author Topic: Suggestions on Assembler programs for ASM.  (Read 95 times)

Sedit

  • Global Moderator
  • Foundress Queen
  • *****
  • Posts: 2,099
Suggestions on Assembler programs for ASM.
« on: January 05, 2011, 09:29:53 PM »
I'm starting to look into ASM again which I have some experience programing for the x86. Most programing I done in the past was with C++ But I will soon start looking into C# as a supplement to my ASM program. What are some good compilers out there today? I haven't programed a lick in about 10 years so be easy on me.

It sounds strange but I have a curiosity that I want to fullfill and that's to make a Virus. Not just a normal virus but one that Mutates so most if not all of my work will have to be done in ASM language.

The idea behind it is to attempt to segment the self replicating programs into packets that can rearrange themselves while still acting as a single program regardless of how it inserts itself into another program. I think of it simular to DNA and upon replication there will be a string value added at the start to point to the various sections. I liken the sections to something a kin to protiens, each segment will have a function but it need not be called. By order of the starting string Key encoded during replication it will allow the stack to call up these various segments at the right time to allow the program to be morphable at its on accord in future versions.

This entire process will ensure that the same identification data to locate the virus would be different each and everytime the virus is replicated.

I also wish to encorperate networking later in the future but I have no idea how to do that from ASM other then possible direct data access to the ports which personally I think will be very hard to do so I believe that is where I would use C++ to encode then decompile it and modify the code slightly to fith the working of the Virus.
There once were some bees and you took all there stuff!
You pissed off the wasp now enough is enough!!!

Wizard X

  • Lord of the Realms
  • Foundress Queen
  • *****
  • Posts: 1,224
Re: Suggestions on Assembler programs for ASM.
« Reply #1 on: January 06, 2011, 12:32:59 AM »
Albert Einstein - "Great ideas often receive violent opposition from mediocre minds."

Sedit

  • Global Moderator
  • Foundress Queen
  • *****
  • Posts: 2,099
Re: Suggestions on Assembler programs for ASM.
« Reply #2 on: January 06, 2011, 01:18:57 AM »
Thanks wizard, that jogged my memory a bit. The assembler I use to use was TASM and it came along side of Turbo c++ I started programing in and was compatible with Borland C++ that I normally used.

The main issue im going to face it the fact that unlike when I was big into programing as a hobby DOS is pretty much dead. I have little windows programming experience other then Visual basic and thats pretty much worthless other then for quick algorithm runs which I use to use it for. I never managed to get the hang of Visual C and I have a feeling that ASM programming for windows will be a bit of a challenge. I have noticed however that it appears simpler to call external library files from NASM simular to library files in C++ but im not sure if I understand this correctly yet.
There once were some bees and you took all there stuff!
You pissed off the wasp now enough is enough!!!

overunity33

  • Subordinate Wasp
  • ***
  • Posts: 218
Re: Suggestions on Assembler programs for ASM.
« Reply #3 on: January 06, 2011, 10:10:51 AM »
learning ASM is a sign that you have too much free time man

Sedit

  • Global Moderator
  • Foundress Queen
  • *****
  • Posts: 2,099
Re: Suggestions on Assembler programs for ASM.
« Reply #4 on: January 06, 2011, 04:21:11 PM »
I have already learned it quite sometime ago, all I need if a refresher course. I went to tech school to "learn" computer science along time ago but I bumped heads with my teacher to much.

To much free time, ;D yeh you could say that. Idle hands drive me nuts. I can't play in the lab as much as I like so back to computer programing it is.
There once were some bees and you took all there stuff!
You pissed off the wasp now enough is enough!!!

Vesp

  • Administrator
  • Foundress Queen
  • *****
  • Posts: 3,130
Re: Suggestions on Assembler programs for ASM.
« Reply #5 on: January 06, 2011, 08:14:28 PM »
That is funny. I am now taking an intro computer science class and the more I look into it the more I like it. If this keeps up for all semester, I may change majors.  :S I have no idea...
Bitcoin address: 1FVrHdXJBr6Z9uhtiQKy4g7c7yHtGKjyLy

Wizard X

  • Lord of the Realms
  • Foundress Queen
  • *****
  • Posts: 1,224
Re: Suggestions on Assembler programs for ASM.
« Reply #6 on: January 06, 2011, 11:25:52 PM »
Thanks wizard, that jogged my memory a bit. The assembler I use to use was TASM and it came along side of Turbo c++ I started programing in and was compatible with Borland C++ that I normally used.

The main issue im going to face it the fact that unlike when I was big into programing as a hobby DOS is pretty much dead. I have little windows programming experience other then Visual basic and thats pretty much worthless other then for quick algorithm runs which I use to use it for. I never managed to get the hang of Visual C and I have a feeling that ASM programming for windows will be a bit of a challenge. I have noticed however that it appears simpler to call external library files from NASM simular to library files in C++ but im not sure if I understand this correctly yet.

MS OS = Microsoft Operating Systems

I disagree. DOS would be the perfect coding for virus writing. I know of a small single one line piece of code, command-line DOS, that still works on all MS OS (that hasn't been patched as yet) that WILL cause considerable damage to the OS and data files. Delivery and execution of the command-line code via internet is the difficult challenge.

Albert Einstein - "Great ideas often receive violent opposition from mediocre minds."

Sedit

  • Global Moderator
  • Foundress Queen
  • *****
  • Posts: 2,099
Re: Suggestions on Assembler programs for ASM.
« Reply #7 on: January 06, 2011, 11:51:56 PM »
Im not looking to destroy any OS at all with the virus because that would be counter productive. My main concern is allowing it to spread without being detected for quit sometime over a variety of systems. The means to do this would be to not allow its signature to remain the same thruout every file it infects so that antivirus software would have very little to go on. As long as the virus did not corrupt the system and it did not show a repeating signature thruout the computer it would lay for possibly years undetected.
There once were some bees and you took all there stuff!
You pissed off the wasp now enough is enough!!!

Wizard X

  • Lord of the Realms
  • Foundress Queen
  • *****
  • Posts: 1,224
Re: Suggestions on Assembler programs for ASM.
« Reply #8 on: January 07, 2011, 01:30:59 AM »
Im not looking to destroy any OS at all with the virus because that would be counter productive. My main concern is allowing it to spread without being detected for quit sometime over a variety of systems. The means to do this would be to not allow its signature to remain the same throughout every file it infects so that antivirus software would have very little to go on. As long as the virus did not corrupt the system and it did not show a repeating signature thruout the computer it would lay for possibly years undetected.

I assumed as much, however, my later post was to express how DOS can still be applied to virus code.

MS, Linux, etc?

Polymorphic virus = Polymorphic code. http://en.wikipedia.org/wiki/Polymorphic_code
Albert Einstein - "Great ideas often receive violent opposition from mediocre minds."

no1uno

  • Global Moderator
  • Foundress Queen
  • *****
  • Posts: 681
Re: Suggestions on Assembler programs for ASM.
« Reply #9 on: January 07, 2011, 01:59:49 AM »
If you have a student account, grab the Microsoft Dreamspark VS2010 (Full), if you don't have a student account, I have several...

I'm looking at OD1N as a base for NMR, quite simply it is open source (open code), Object Orientated C++, which allows for basically any system and also has integrated pulse shaping libraries for Spin-Echo routines. I currently (based on the modeling) have a magnet design that will give 1.074 +/- 0.001 Tesla in a 5x5x5mm cube area in the center of the sample volume area (so it is kind of homogeneous), with that and the various pulse-shim/shim-pulse routines there is a real possibility of getting NMR working @44MHz.

I'm also looking at Microsoft Robotics studio as well as both PIC & TI (Launchpad) for the MC/DSP to generate the signal & pulses.

Is there any way we can modify OD1N so that the basic program could be used for multiple spectroscopic outputs (including light based)? A single GUI that could be used to run all the various systems and to get all the data in one place would be great.

I'm busy writing a Business Plan for additional funding, I have an agreement with a certain Associate Professor, I'll supply him with a magnet assembly, he'll supply me with the electronics to go with it (and he'll also write it up). Trouble is, he has kind of gone overboard on the electronics, I personally see no reason for an FGPA when a simple DSP (Digital Signal Processor)/MSP (Mixed Signal Processor)* will do the job as effectively, without the enormous code/cost overhead. Trying to design systems that can work by themselves is one thing, however, not making use of the incredible amount of computing power in the average study PC/Laptop is just dumb.

That said, the average potential user of these systems is not going to set out to spend 4 or 5 times the price of the complete system in order to get the feel for building an untested & unknown unit themselves. If the price were right, quite frankly they'd prefer to simply purchase something they already know works.

* Especially when you have things like the MSP430 series, with the 64QFN chips having up to 128kB Memory, with USB 2.0 port access built in, for <$10 each (MSP430F5528 looks nice @ $3.95 each, especially with CCS onboard).
« Last Edit: January 07, 2011, 02:22:45 AM by no1uno »
"...     "A little learning is a dang'rous thing;
    Drink deep, or taste not the Pierian spring:
    There shallow draughts intoxicate the brain,
    And drinking largely sobers us again.
..."

Sedit

  • Global Moderator
  • Foundress Queen
  • *****
  • Posts: 2,099
Re: Suggestions on Assembler programs for ASM.
« Reply #10 on: January 07, 2011, 02:31:29 AM »
Wizard that is great, I knew it was a good idea and that theres no way I was the only one to think of it but I didn't know where to start. Polymorphic code looks good but further searching reveals that Metamorphic code may be better suited to my needs as it has the ability to store various copys of a virus into a single formate and then convert it on replication to the desired OS.

I believe thats still way out of my range right now however.
There once were some bees and you took all there stuff!
You pissed off the wasp now enough is enough!!!

akcom

  • Dominant Queen
  • ****
  • Posts: 430
Re: Suggestions on Assembler programs for ASM.
« Reply #11 on: January 07, 2011, 06:43:40 AM »
metamorphic code is going to involve essentially writing your own compiler...in assembly  polymorphism is a much more attainable goal, and can even be written using C.

as for network code I'm going to assume you're writing this on windows so you'll be using ws2_32.dll.  To load it in a "discreet" fashion, find the base address of kernel32.dll via one of the many published methods, walk it's export table until you hit LoadLibraryA and GetProcAddress, store the corresponding addresses.  To avoid having suspect strings in your code you could use a simple 32 bit hash function and do the comparison that way.

I used write this sort of shit for fun back in the day.  Rootkits were more fun though IMO.  Best is when you write it in ASM and inject into another driver (beep.sys is an old fav) either in memory or on disk.

edit: I always used NASM, but that was just personal preference

Wizard X

  • Lord of the Realms
  • Foundress Queen
  • *****
  • Posts: 1,224
Re: Suggestions on Assembler programs for ASM.
« Reply #12 on: January 11, 2011, 06:37:27 AM »
metamorphic code is going to involve essentially writing your own compiler...in assembly  polymorphism is a much more attainable goal, and can even be written using C.

Albert Einstein - "Great ideas often receive violent opposition from mediocre minds."

timecube

  • Subordinate Wasp
  • ***
  • Posts: 230
Re: Suggestions on Assembler programs for ASM.
« Reply #13 on: January 11, 2011, 08:55:56 AM »
Before looking into polymorphic code or any other techniques, you need to write out a business plan of sorts outlining what your goals are and who your targets are.  Are you after financial data, webcam recordings to get n00ds of your girly friends, a generic botnet to lease out to spammers and DDOSers.. etc.

Are you targeting corporate machines or personal machines?  They have vastly different security procedures.

Antivirus programs work in two ways:  they identify viruses based on various checksums and they attempt to use heuristics to identify unusual behaviors (like remote thread injection, unusual packing mechanisms, modifications to code segments, etc.)  Unless you've spread at the level of the Storm worm the first isn't usually that large of a concern, but it can be tricky to avoid the second.  Trying to purposely change the form of your program can sometimes make it look more suspicious unless you're careful about it.  You generally want to get as deep as you can as quickly as you can and stay there, via kernel and driver exploits, so you can undermine detection efforts.

If you're looking more at using polymorphism on the actual infection packets, those are usually only blocked by IDS systems on corporate networks anyway.  I think you'll find that your design goals vary greatly with your targets, infection vector, etc.

I like seeing that there is such an overlap between underground chemistry, underground IT, etc.  A powerful second world has been developing for years.  There's a large class of people growing who realize life has a lot more to do with who can outsmart whom than with arbitrary decrees of legality.

Anonymity

  • Larvae
  • *
  • Posts: 6
Re: Suggestions on Assembler programs for ASM.
« Reply #14 on: January 11, 2011, 05:34:49 PM »
If someone like sedit where to design a virus of sorts with the ability to lay low in systems till a blanket of infections has occured world wide he would more then likely wish to have it start operations at a set time in the far future directing DOS attacks and other functions useful for there goals. The attacked IP adresses would more then likely be preset into it inabling a DDOS comming from hijacked systems from a large area of the net. Some sites will need to be cracked and blocks of information gathered to the best of abilitys then transfered over a range of sites preferably thru a TOR system to be decrypted. Its primary function would be to target personal machines that would later access corporate machines.

The highjacked computer needs as little information as possible that it is even being used for such a task and it should return to baseline as quickly as possible as to hinder normal operations of the system as little as possible.

That sure seems like a large task for one man to accomplish if thats Sedits goals. ::) . All of that would be highly illegal though and Sedit seems like a straight laced sort of guy so im sure thats not the plan right Sedit? :-X

Sedit

  • Global Moderator
  • Foundress Queen
  • *****
  • Posts: 2,099
Re: Suggestions on Assembler programs for ASM.
« Reply #15 on: January 11, 2011, 05:39:26 PM »
Correct that would be illegal, I just want to play around with code at the moment and see if theres a means to beat virus scanners and other security measures to make a virus stay undetectable for years as long as its not doing anything to draw attention to itself I see little reason for a heuristics model to be created in order to detect such a thing.

Modifications of a tiny virus to encrypt itself should keep general operations at a small level at first.


Its all just a complicated study in biology nothing more... Although the points brought up by Anonymity fellow are definitly worth discussing.
There once were some bees and you took all there stuff!
You pissed off the wasp now enough is enough!!!

akcom

  • Dominant Queen
  • ****
  • Posts: 430
Re: Suggestions on Assembler programs for ASM.
« Reply #16 on: January 11, 2011, 06:27:19 PM »
If you aren't worried about modifying your encryption routine, a polymorphic virus is quite easy to write.  Not getting caught by heuristic scanners is a different beast all together.  If you'd like some code examples just let me know.

Sedit

  • Global Moderator
  • Foundress Queen
  • *****
  • Posts: 2,099
Re: Suggestions on Assembler programs for ASM.
« Reply #17 on: January 11, 2011, 11:30:11 PM »
I would love code examples matter of fact since reverse enginering is what I do best in programing.
There once were some bees and you took all there stuff!
You pissed off the wasp now enough is enough!!!

Wizard X

  • Lord of the Realms
  • Foundress Queen
  • *****
  • Posts: 1,224
Re: Suggestions on Assembler programs for ASM.
« Reply #18 on: January 12, 2011, 12:00:13 AM »
If you aren't worried about modifying your encryption routine, a polymorphic virus is quite easy to write.  Not getting caught by heuristic scanners is a different beast all together.  If you'd like some code examples just let me know.

I would like to see the examples to thanks.
Albert Einstein - "Great ideas often receive violent opposition from mediocre minds."

timecube

  • Subordinate Wasp
  • ***
  • Posts: 230
Re: Suggestions on Assembler programs for ASM.
« Reply #19 on: January 12, 2011, 12:56:27 AM »
A pseudocode example might help show potential overall flow design as well.

For this example, say you have a simple buffer over exploit like the Slasher worm, etc. where everything is contained in one packet and when it gets to the server it starts sending out copies of itself.  You could use something like the following:


Exploit portion
===================
[control data]
[long random string to overflow buffer]
[return address - this could even be varied by pointing it to random locations with jmp esp instructions]

====================
Code portion
====================
[optional random length string of effective nops (inc eax;   dex eax;   xor ecx, ecx;  etc.]
[code to base64 decode block X]
[code to decrypt block X using key YYYY - this could be as simple as an xor loop]
[jmp block X]
[YYYY]

[Encrypted, base64 encoded block X]



where X decrypts to something like:

[allocate space for packet Z]
[copy control portion of packet into Z]
[seed random number generator]
[fill buffer length in Z with random data (other than NULL or whatever)]
[pick a random return address out of a list of useable ones (in this case addresses of jmp esp insructions) and copy it to Z]
[pick a random length and fill it with random effective nops (in Z of course)]
[copy base64 decode block into Z, altering instructions randomly as much as possible while still retaining functionality]
[copy decryption block into Z, altering instructions randomly as much as possible while still retaining functionality]
[choose a random value for YYYY (again avoiding nulls) and copy it into Z]
[make an encrypted copy of this entire X block using the new YYYY inside of Z]
[base64 the encrypted copy (to get rid of nulls.. you could use any encoding that will help with this, or a different encryption process to begin with that avoids nulls somehow)]
[your new packet is now ready to go and has everything it needs in it, so fire it off to a random IP, then loop back to the start of this X block]
============end of X==============

The decoding and decryption code are the only things that remain somewhat constant, so the more you can alter it each round the better.
the jump to block x could even be altered (eg. xor eax, eax;  je X     ||or||   xor ecx, ecx;  dec ecx;  jne X)

It's important to realize that you're making an encrypted copy of the entire currently running block (including the parts you haven't executed yet) but since the output of the encryption and encoding is in another part of memory, it's not going to affect the currently running code.


When you get into doing this kind of thing in executables, you can get even more creative.  Microsoft hid it's Patchguard initialization functions in an error handler, then purposely caused a divide by 0 error in the middle of a seemingly innocuous part of the kernel code.  Heuristics-based AVS often look for self-modifying code and data execution, so you sometimes have to find clever ways around these problems.
« Last Edit: January 12, 2011, 01:34:48 AM by timecube »