Articles

Metasploit Framework Windows Tutorial
Remote Desktop Connection
Windows Processes That May Be Dangerous
How-To use NetCat a Tutorial
Common Linux Commands
Common Ports
Netcat Commands
HTTP Response Codes
War-Google Hack Terms
Wardriving
Avoiding Social Engineering and Phishing Attacks
Intrusion Detection on Linux
Linux Intrusion Detection
Penetration Testing Guide
Penetration Testing Tools
Social Engineering Fundamentals, Part I: Hacker Tactics
Social engineering (computer security)
The Psychology of Social Engineering

The Archives

General GSO
GovernmentSecurity.org News & Suggestions
In The News
Open Topic
General Security Information
Trash Can
Exploit & Vulnerability Mailing List Archives
Trial Member Forum
Product and Program Reviews GSO Tutorials
System Security
Windows Systems
Beginners Section
Linux & Unix Systems
File Downloads
Exploit Research & Discussion Trojan & Virus Errata
Networking Security / Firewall / IDS / VPN / Routers
System Hardening
E-Mail Security
Wifi Security
Trial Member Uploads
Upload discovered Trojans & Mal ware
GSO Programming Section
C , C++ , VC++
Visual Basic.NET
Perl /CGI
Java/Javascript
PHP/XML/ASP/HTML
Assembly + Other
The Cork Board
Network Security Consultant Directory
Network Security Jobs
The Archives
Encryption Information
General Network Security
Internet Anonymity
HTTP Protocol Security
Linux Security
MS IIS Information
Exploit Articles
Programming / Tool Design
GSO Software Projects
Public Downloads
Microsoft Security Questions and Papers

nuorder
I didnt seen any windows compiling tutorials like this so i thought i'd write one and link to some other threads on this site to save a bit of searching
It may be a good idea to evolve this if i think of more to add or someone else does
If anyone has anything to add about this or point out a problem with any of the explanations then feel free to correct me and i will ammend this mini tutorial

BASICS
----------
Most of you know this but some dont so here we go.

What is C and C++
They are programming lanuages, C++ is basically object oriented C (a very generalized comparison)

What is a Compiler
You have some source code, you can read it but your computer cant - it only understands binary. So a compiler translates this source code into machine code (binary) and creates an exe file

COMPILING
--------------
I need a free C compiler
There are many out there and some are down to personal choice
For starters lcc is not too bad and you can download it from www.cs.virginia.edu/~lcc-win32/
Or to compile linux code under windows use cygwin www.cygwin.com (you will need to select the c and gcc packages)
For other compilers and more cygwin info see the link near the end of this post

What are all those #includes .h files and why dont i have them
To save having to write the same code over and over ie: functions to send packets over a network, programmers use headers files (donated by the .h filetype) which already contain the code that does this.
Most standard libraries (libraries are sometimes many .h header files) come with your compiler and are located in it's /includes folder
Also when including files
#include "header.h" - means that header.h is in the same folder as your code
#include "C:\stuff\header.h" - header.h is in the C:\stuff folder
#include <header.h> - header.h is in the /include folder of your compiler which is the most common unless making your own

How do i know if this will compile under linux/cygwin or windows
You can sometimes tell by the header files that are included in the sourcecode
Common Windows includes
#include <winsock.h> - used to access the network
#include <windows.h> - defines windows structures and messages (eg: so we can use a word instead of some hex number for a value)

Common Linux includes
#include <netinet/in.h> - sockets/networking
#include <sys/socket.h> - defines socket structures

I downloaded the required header file but its still says some are missing
Header files can include other header files too so you will have to get them all. Sometimes if you are missing too many headers then you may require a development package eg: openssl which is used for a few crypto programs (eg: rainbowcrack)
For a brief tut on compiling openssl see here http://www.governmentsecurity.org/forum/in...?showtopic=9142

Is this code C or C++
normally the author's comments (if any) at the top of the code will tell you whether its a .c or .cpp filetype
If it is including <iostream.h> and uses commands such as 'cout' and 'cin' then its a C++ filetype

My compiler complains about ws2_32 or i see #pragma comment(lib,"ws2_32") in the code
In your compiler you may have to include the winsock library ws_32.lib for defines and functions in the includes to be recognised by the linker when compiling
its generally located in the lib directory of your compiler but isnt always added by default
you just have to find the part of the config in your compiler where you can add this library to the libraries which it will link to when you compile this code
ie: VC++ has project->settings->link

It still doesnt compile so what do i do
Post the error messages the compiler gives you and what compiler you are using. saying things like "it doesnt compile" or "can u plz compile i got errors" doesnt help you

USING EXPLOITS - Common sense
----------------------------------
What port does this run on / what port do i scan
You have to read through the code to find it

Is this Local or Remote
The author's comments at the top of the sometimes will tell you, but if not then read the security advisory for the exploit.

What does this sploit do
You dont know so you dont need it

For compiling under Linux/cygwin i suggest you read these threads
http://www.governmentsecurity.org/forum/in...?showtopic=6976
http://www.governmentsecurity.org/forum/in...?showtopic=2955
http://www.governmentsecurity.org/forum/in...hp?showtopic=39
http://www.governmentsecurity.org/forum/in...?showtopic=9504
http://www.governmentsecurity.org/forum/in...showtopic=10304

Other Compiling based threads on this site
--------------------------------------------------
Compiling
http://www.governmentsecurity.org/forum/in...?showtopic=2362
http://www.governmentsecurity.org/forum/in...?showtopic=9198

C programming tutorials
http://www.governmentsecurity.org/forum/in...p?showtopic=704

C compilers
http://www.governmentsecurity.org/forum/in...p?showtopic=939
http://www.governmentsecurity.org/forum/in...p?showtopic=706

Online C compiler
http://www.governmentsecurity.org/forum/in...?showtopic=2100

Compiling with .NET
http://www.governmentsecurity.org/forum/in...?showtopic=8084

Header Files (.h)
http://www.qnx.com/developer/docs/momentic...20of%20Contents
http://handhelds.org/download/intimate/release/usr/include/
also google could help you here. search for "index of" headerfile.h

oh and i cant forget good ol www.codelinx.net
ZoraX
Very very good tut smile.gif

Hopefully now ppl try to compile the exploits themself, before asking in the forum smile.gif
Great work:)
z0mbi3
nice work. Maybe this can be pinned so it won't get lost
Terminal
Someone pin this topic so if someone do try to start topic relating to compile request will see thi b4r smile.gif
mortello
QUOTE (vicky @ Aug 11 2004, 02:23 PM)
Someone pin this topic so if someone do try to start topic relating to compile request will see thi b4r smile.gif

Was gonna say the same

Good job on the tutorial too smile.gif
Krogoth
i suggest the mod make it sticky. surely this is a nice tut.
great job nuorder.
DeGast
Yeah Thx m8

I was looking for a Tut.


Gonna try this one!
DougieShiney
good tutorial on compiling source code ... thanks
tibbar
the best advice i can give regarding compiling exploits, is to learn to program in c / c++. most exploits that you find on the net will be full of "anti-kiddie" devices - i.e. errors added to the code to stop it from compiling.

you will need to be able to recognise these from the compile errors and repair the code.
Daisycutter
here is a noob question.

can you complie c++ source in VB or VC++ ?
6066up9r
great tutorial, thanks for taking the time to link the other threads as well!
Learnsecurity
good tutor, thx
Terminal
QUOTE (Daisycutter @ Aug 15 2004, 04:03 PM)
here is a noob question.

can you complie c++ source in VB or VC++ ?

You can compile in VC++
nicolas9510
thanks, that was a very helpful post for me being a noob programmer !!
IcedOut3E
Definetly worth of a sticky....


Thanks.
o0oKARo0o
Excellent tut, thanks man!
tyler.durden
very good start point... thanks alot wink.gif
Aragornian
Thnx a lot man smile.gif
I was still looking for a free compiler,.
Tried some before,. but somehow it never worked out the way I wanted it to tongue.gif
beardednose
Nice work. I tried to PIN this, but couldn't. Comsec? Diss?

This would also be a good time to remind many of you that posting "Thanks" and such posts will cost you points.

No one wants to read 15 folks saying "Thanks." If you don't have anything else to say beside THANKS, then hold your tongue.

The original poster will get thanked enuf...

BN
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2005 Invision Power Services, Inc.