bidvertise
Posted by Gagandeep on Sunday, May 15, 2011
How to inject code into a exe file
Posted by Rahul Ghotekar (InOx) in Developer Tools, Hacking tools on Wednesday, May 11, 2011
*** THIS TUTORIAL IS ONLY FOR EDUCATIONAL PURPOSES!*** -Requirements- -Getting started- ***** START QUOTE FROM THE WIN32 PROGRAMMERS REFERENCE int MessageBox( ***** END QUOTE FROM THE WIN32 PROGRAMMERS REFERENCE -Some ASM- -Last Words-
At first we need a debugger. I prefer OLLYDBG(the best debugger on earth :P)
At twice we need a target application to inject our code.
I will take the windows NOTEPAD.EXE .
Make a copy if this EXE in a new folder named CodeInjectTest.
Thats all ;)
Our goal is to inject some code into the Notepad.EXE .
In our case we'll inject a simple MessageBox at Notepads start.
Start up Notepad now and validize that Notepad is the original one.
[My Notepad screenshot]
If you're sure now that's the original Notepad open the Notepad.exe with Olly.
Yuppi! If you're ready you get this window:
[click to enlarge]
Because we're going to inject some code we've to have some space to inject it.
In a EXE file are a lot of CodeCaves were nothing is done (DB 00).
So lets scroll the CPU window a little bit down until you find a CodeCave(look below).
[CodeCaves]
Do you see the red box I've drawn for you? ;) THIS is a CodeCave!
Here we can inject some custom code without interfering the programs flow.
If you know the API call for a MessageBox you don't need to
read this lines.
The MessageBox function creates, displays, and operates a message box.
The message box contains an application-defined message and title,
plus any combination of predefined icons and push buttons.
HWND hWnd, // handle of owner window
LPCTSTR lpText, // address of text in message box
LPCTSTR lpCaption, // address of title of message box
UINT uType // style of message box
);
This is all you need to know about the MessageBox.
Now its time to do something with the CodeCaves.
At first to use the MessageBox we need to create some text for output it on the
MessageBox. In the following picture I've selected some lines of the CodeCaves and
highlighted the BinaryEdit menu for you.
If you pressed on Binary=>Edit or (CTRL+E) you will see following window.
Just fill it out like me if you want.
Press OK and you'll see the modified code in red:
Press now CTRL+A to reanalyze the code.
OK! If you want to have a different MessageBox Caption than the title you can repeat this
step to make a second ASCII like the "INJECTED NOTEPAD".
Now its time for some ASM ;)
We need to invoke a MessageBox from ASM. This is quite simple!
PUSH 0 ; BUTTONS =
PUSH 1008751 ; CAPTION = Our adress of the "INJECTED NOTEPAD"
PUSH 1008751 ; MESSAGE = Same like above.
PUSH 0 ; ICON =
CALL MessageBoxA; Run MessageBoxA with the Params above.
This few lines entered in Olly should look like this:
Do you see the arrow?! THIS IS NOW A VERY IMPORTANT STEP!
If we save it now and run it you will NOT see any effect. Why?
Because our litte routine is not called yet!
You need to write down the Offset of your first "PUSH 0" because we
need to make a jump from the programs origin to here and back again ;)
If you noted the offset of the first PUSH down, goto the origin of the program like below.
Now you're at the FIRST line of code which will be executed.
Do you remember that the first thing we wanted to do is to run our code? :)
Yehaa! We're on the right way!
Select now from the origin some lines and copy it into the Clipboard.
Paste the clipboard into a texteditor and leave them there. We need this lines later.
If you have pasted it go to the first line of the program.
(In the picture upper it's the PUSH 70).
Double click on it and enter in the box "JMP
Press on Assemble and you will the the again the red marked(patched) code.
Look to the redbox! This is the address we need to jump to after our injected code.
If we jump here after the injection the program will execute like without our injection :)
But there is one thing we need to do at least!
Compare the "new" origin with the old one you've pasted into a clipboard.
You will see that there are a few lines overwritten! But this lines are needed to run
the programm without errors. Identify the lines which get overwritten.
In my case the overwritten lines are:
PUSH 70
PUSH NOTEPAD.01001898
Click on the first line (our JMP) and press ENTER.
You'll dropped to your MessageBox invokation!
After our CALL MessageBoxA we need to insert now the overwritten lines AND the jump back!
NOW you're done!
(If you want to test the "JumpBack"-Jump just select it and press ENTER.
If you get to the right line you can be sure that's ok! If not check Offset!)
To save the "new" Notepad take a look the the following picture:
If you press on "All modifications" a new little window will be shown.
Press on "Copy All" on this window.
A new window with the new ASM code will be shown.
Close the new window (THE CHILD WINDOW! NOT OLLY DBG WINDOW!).
Then a save dialog let you choose a new filename.
Save the file and run it. If you're successful you will get this result:
Press on OK and Notepad will start normally ;)
DO NOT abuse debuggers to attach shellcodes or things like that into EXEs!
Most Essential Free Softwares After Windows Installation
Posted by kk in Internet Tools, System Utilities, Useful Softwares on Thursday, March 24, 2011
As a Windows lover, I have always tried to make it more secure, convenient and easy to use. This is my must-have list of Free Softwares and Utilities that I use as an installation checklist on every fresh Windows installation. After these are installed, Windows is much more stable and powerful. These apps and utilities are my top picks as most essential to install on every Windows PC. These programs allow Windows to operate more securely, making the system more reliable, which helps me complete my work easily and effectively. I have listed them in alphabetical order. Digsby Universal Extractor VideoLAN VLC media player If we are missing something, please feel free to add that in to this list.Avira AntiVir Personal Edition
Consistently at or near the top of independent efficacy testers, Avira’s AntiVir remains one of the best freeware security solutions around. Its scans are flexible, allowing the user to fully scan both internal and external hard drives, run a preloaded scan–for rootkits, for example–or customize a scan.
CCleaner
CCleaner is a freeware system optimization, privacy and cleaning tool. It removes unused files from your system – allowing Windows to run faster and freeing up valuable hard disk space. It also cleans traces of your online activities such as your Internet history. Additionally it contains a fully featured registry cleaner.
Digsby helps you manage all your IM, e-mail, and social network accounts from one easy-to-use application. Digsby lets you chat with all your friends on AIM, MSN, Yahoo, ICQ, Google Talk, Facebook Chat, and Jabber with one simple to manage buddy list. It provides notifications when new e-mails arrive.
DAEMON Tools Lite
DAEMON Tools is an advanced application for Microsoft Windows which provides one of the best optical media emulation in the industry. With DAEMON Tools you can back up your physical CD/DVD/HD DVD/Blu-ray discs into “virtual discs” or so called “disc image” files, which run directly on your hard drive. You can also work with images created by other burning programs! DAEMON Tools supports variety of image types.
Everything search engine
This small software application bypasses Windows search with a lightning quick interface and real-time results for all of the files and folders in your local hard drive or any subsection of it. The software doesn’t do much more than search, but its efficiency, effectiveness, stability, and low system resource usage make it a keeper utility.
Firefox
The Firefox Web Browser is the faster, more secure, and fully customizable way to surf the web. Mozilla Firefox is a fast, full-featured Web browser. Firefox includes pop-up blocking, tab-browsing, integrated Google search, simplified privacy controls, a streamlined browser window that shows you more of the page than any other browser and a number of additional features that work with you to help you get the most out of your time online.
FileZilla
Rich in Web content, short on cash? This free, open-source FTP application is handy if you’re looking for a solid tool to handle FTP transfers and don’t want to part with your bucks.
Flash Player (Adobe)
Adobe Flash Player software is a cross-platform browser plug-in that delivers breakthrough web experiences and is installed on more than 98% of Internet-connected desktops. Flash Player 10 introduces 3D effects, custom filters and effects, advanced text support, and more.
Flashget
FlashGet is specifically designed to address two of the biggest problems when downloading files: Speed and management of downloaded files.
Foxit Reader
To put it gently, Adobe Reader is a real pain in the hindquarters. It’s monstrously large, slow to load, and includes many features most users will hardly ever need. Foxit PDF Reader 3.0 kills the bloat and throws in some useful features, such as multimedia support and content-sharing options, while still allowing you to quickly access your PDFs.
Google Chrome
Google Chrome is a browser that combines a minimal design with sophisticated technology to make the Web faster, safer, and easier. Use one box for everything–type in the address bar and get suggestions for both search and Web pages.
ImgBurn
ImgBurn is a lightweight CD/DVD/HD-DVD/Blu-ray burning application that has several modes, each for performing a different task: Read; Build; Write; Verify; and Discovery. ‘Advanced’ input mode to build mode where you have total control over the layout of the disc and can add new folders, change names etc. and Optional logging when hidden or system files/folders are skipped in Build mode due to the current settings.
K-Lite Mega Codec Pack
With the K-Lite Codec Pack you should be able to play all the popular movie formats and even some rare formats. This package is mainly for power users and people who do their own encodings.
Notepad++
Notepad is a Notepad replacement with an eye toward programmers, although it should also appeal to the casual user who wants a cross between Notepad and WordPad. Notepad has some noticeable differences from WordPad. Support for tabs is key, letting users manage different documents simultaneously.
OpenOffice.org
A credible rival to MS Office, OpenOffice.org includes powerful applications for making text documents, spreadsheets, presentations, diagrams, and databases, as well as HTML and XML documents. Not only does it let you edit basic documents, such as letters and faxes, it also handles equations and complex and multipart documents with bibliographies, reference tables, and indexes.
Process Explorer
If you’ve ever tried tracking down a process in Windows Task Manager, you know it’s like looking for a needle in a haystack. Process Explorer makes the job a lot easier. This freeware utility displays running processes in an intuitive tree format that includes not only process names, but also program icons and other data, such as description, image, and processor time.
Universal Extractor is a program do to exactly what it says: extract files from any type of archive, whether it’s a simple zip/rar file, an installation program, or even a Windows Installer (.msi) package.
Unlocker
Ever had such an annoying message given by Windows: Cannot delete file: Access is denied. There has been a sharing violation. The source or destination file may be in use or the file is in use by another program or user. Make sure the disk is not full or write-protected and that the file is not currently in use. Unlocker is the solution.
VLC is a highly portable multimedia player for various audio and video formats, including MPEG-1, MPEG-2, MPEG-4, DivX, MP3, and OGG, as well as for DVDs, VCDs, and various streaming protocols. It also can be used as a server for unicast or multicast streams in IPv4 or IPv6 on a high-bandwidth network.
Vuze (Formerly called Azureus)
Vuze is the easiest way to find, download,and play HD movies, TV and videos. Download and stream using the most powerful p2p bittorrent app in the world.