Friday, August 26, 2011
DLL Injection: How viruses hide themselves?
1. Allocate memory in the victim process and write your code in that space and spawn a new thread from that address.
2. Or the better one(and more preferred one too), load a malicious DLL forcibly in the victim process.
I'll discuss more on way 2. The code will be divided into two modules:
1. Malicious DLL : This is the binary containing all code to do specific tasks. Viruses put all code related to replication, hooking, logging etc in this DLL.
2. Injector process: This is the short lived process. The task of this process is just to inject the dll
into the victim process(say explorer.exe) and then it dies out.
In this blog entry, I'll discuss more on Injector process working:
1. Get handle of the victim process: In windows, there are multiple ways to do so. You can either get the handle by using process name or its PID or even process window's title(in case it is a UI process). There are multiple APIs to do so like OpenProcess()
2. Once you get the handle, you need to start a new thread in the victim process and ask this thread to load your DLL. To do this, you need to set starting address of the newly created thread to LoadLibrary and corresponding argument set to the address of wchar string containing name of the DLL. So, before you do this, you need to allocate some memory in victim process and write DLL in it. Once you have written the name and have called Loadlibrary with right argument, you are good to go. OS will do rest of the things for you :)
It will automatically call the DllMain in your DLL and your work is done. You can execute any damn code via that DLL in the address space of the trustworthy process and there is no easy way to detect it.
In the next post, I'll tell you the ways by which you can detect whether any process on your machine has been injected with any DLL.
Disclaimer: The intention of this process(and the other posts following this one) is not to encourage DLL injection but to increase awareness about it so that one can safeguard oneself against these things. I'll restrain myself from posting any directly working codes..
Thursday, August 25, 2011
Back...
First post coming soon on Dll injections..
Saturday, September 20, 2008
Test vs Development
- Which is better: A Test job or a Development job?
- Which one to prefer: A Test job or a Development job?
- Is switching between the profiles possible later?
Friday, August 15, 2008
3 'S' of coding
Most of us feel that developing algorithm is the main part of whole SDLC(Software Development Life Cycle) which is actually not the case. We, generally, ignore the vital part of coding and do it in our stride. Here, I am mentioning the 3 ‘S’ of coding which one must take care always:
1) Simple: As they say, "Think simple, think better". Keep the design as simple as you can(of course, it should be meeting all functional specifications). One thing worth noting with simplicity is that generally, the first thought that comes to our mind is simple and better. We are the one who make it complex later. So, Believe on your first idea.
2) Scalable: You design should be scalable enough. By scalability, it means “It should be modular enough to accommodate further changes in requirements without modifying much at the base level.” For example, if the logic of your problem demands reading/writing from/to an XML file, you have two ways to do this:
a. Either do normal XML parsing using XMLDocument Class Object(in C#).
b. Use concept of Serialization/Deserialization to derive object out of classes(formed from XML Schema(Xsd)) and populate those object. This will save you at later stage when you need to do some changes in XML. Using this method, you need to just change your schema and voila , you are done! No need to modify hard code.
Clearly, scheme 2 is more scalable. But as you can see, Simplicity and Scalability often contradicts each other. It needs a great combination of experience and expertise to make a balance between two.
3) Standard: This is one of the thing, we ignore the most. But, this is the most important ‘S’ out of 3. Being Standard means following some standard notations, that are followed in industry. This benefits in two ways:
a. Following standards makes the code easy to debug.
b. It also help the followers of your code in easy understanding.
Different languages follow different standards, but common ones are:
i. Identifier Naming: Using camel casing for variable names and Pascal notation for properties and functions. Identifier names should be fully descriptive e.g for a varible which stores the count of old customers in an airline, use variable name as oldCustomerCount rather than using some fundoo names as oldcustcnt or CustmrCnt. Adding few extra characters won’t affect you much in this world of Intellisense and all.. Will it?
ii. Adding Comments: Adding comments to code is also an art. It’s not that you add whatever you want to. It also follows few standard conventions like adding name of the editor, date and time of comment etc.
iii. Indentation and Line Folding: These are generally taken care of automatically in advanced IDEs like Visual Studio, Eclipse etc and need little from side of programmer. Of course, you need to take care if you are using some ancient compilers like Turbo C .:)
iv. Minimal use of Public members: One should use public variables in classes(in C++, C# etc.) as less as possible. Rather use private variables and properties(get and set) derived out of them.
Also, few other things like preferring Asynchronous Callbacks over Continous Polling are also counted as Good programming skills.
So, merely developing algorithm is not enough. You need to implement them by coding and coding well. You will have to do trade-offs among 3 ‘S’ of coding at various stages but that’s how you develop and mature. Isn’t it?
Happy Coding :)
Saturday, August 2, 2008
Party Time !!!!
After movie, again some window shopping, eating Ice-Creams, Chuski(especially Wild Cherry for Mukul), chocolate cakes.... I was liking this vellapanti(not very much used to it :)). Reached home at around 7 something. Really enjoyed the day..
After 2 months of extreme hard work, this was required to regain energy and freshness... With college starting from Monday(It's too early:( ), there is much in store for me...
Wednesday, July 30, 2008
A Journey of Life
success.
These days, I 'm living best part of my life. I'm rewinding myself after 2 months of extreme hard work. I have plenty of time to explore other interests these days and hence I'm trying out new things. So, one of the thing I thought is that I should write a blog and here am I... Few other plans to follow: To join a gym and work on my physique and to learn guitar etc.
In this blog, You'll find out stuff related to my experience with life, experiments I did with life, my internship experiences, my future plans and lots of stuff related to computer, technology and philosophy.
So, stay with me and check this blog to experience " A Journey of Life".
