Recursive File Search in C | Source Code
This source code below is written by se7en from LeetCoders. It is capable of running through the enter C drive in 8 seconds on my computer finding more than 230,000 files. Although the downside of it is that it costs quite an amount of CPU usage during its process. You might try to optimize it by placing Sleep function or something that is possible in reducing the CPU usage.
HTTP File Downloader for Linux and Windows in C | Source Code
A member in HackForums by the handle Jakash3 has posted a source code on how to download files from the Internet that can be compiled in both Linux and Windows. Another great feature is that it supports IPv6.
The official way of writing a crypter in C | Source Code
mindlessdeath, a member from HackForums have posted a thread regarding how to write a crypter in C! I find this source code a very good example for people that are trying to learn to write their own crypter. Compared to any other source codes that are posted on the internet, the author of this source code gave a very detailed information on each line on what the statements does. In order to use this source code without much trouble, there are some prerequisites that was mentioned by the author himself.
Clone or Copy File in C
Generally there was someone in one of the forums i am on was asking how to duplicate a file. So basically this little post i made up was to help this guy. There are fundamentally few ways so i will write them up in code tags below.
Learning to make your own DirectX game in C and C++
This is a tutorial that was given by one of the professor in my university that my friend was studying. He is in the gaming course so basically he learned some flash programming and now 3d programming too. Some of the subjects include DirectX so the professor gave them a website that guides you from the basics. This website is called DirectX Tutorial.com and the website is as below. Although i am not fancy of writing anything related to graphics i find that it is quite an interesting subject. By learning how to write with D3D (Direct 3D), a C or C++ programmer may find it useful for their future projects. To jump start the tutorial, visit here.
Homepage: http://directxtutorial.com/
Note: If you are looking for the DirectX SDK it is here.
Listing processes for all users in C
While i was searching online for a way to display processes for all users, i came across this source code which was coded profesionally. The source code can be found here. Be sure to check their homepage here too for more source codes.
Win32 samples
Today i came across a very interesting website while searching for a method to display processes for all users! This website, http://win32.mvps.org/ provides alot of useful information coded in C! As a C/C++ programmer, it is highly suggested to give this website a visit! As for the source code i was looking for (displaying processes for all users), it is here!
Visit it for a better you here.
Creating your own driver loader in C | Driver Loader | Source Code | Rootkit
Technically, there's 2 way of loading a rootkit according to Greg Hoglund when he wrote Rootkits: Subverting the Windows Kernel book. One is called The Quick-And-Dirty Way to Load a Driver. This method allows you to "load a driver into the kernel without having to create any registry keys. "Pageable" refers to memory that can be swapped to disk. If a driver is pageable, any part of the driver could be paged out (that is, swapped from memory to disk). Sometimes when memory is paged out, it cannot be accessed; an attempt to do so will result in the infamous Blue Screen of Death (a system crash)" by using an undocumented API call.
Placing an image file in an executable in C
If you ever wanted to place an image file into the executable or store any resources in it, this post will be able to help you. If you have previously read Builder & Stub | How to create your own builder and stub in C (using Resource), you will be able to understand this post easily. We are using the similar method by placing the image in the resource data. In this post, i am creating an application that extracts the image that has been placed in the resource data and place it in a file and execute the file.
Builder & Stub | How to create your own builder and stub in C (using Resource)
If you are looking to build it using EOF, look here.
As i have already created a similar post which creates your own builder using the File I/O (Input/Output) operation, some have came across a problem where they need their stub application to be placed and ran in memory instead of normal execution. In order to counter this problem, the solution that can come into mind is to use the resource data in the file. Even if your file is ran in the memory, the resource data is also loaded with it. Be aware that the terms used may confuse you so read the synonym section. Take a look at the concept below.
Builder & Stub | How to create your own builder and stub in C (using Resource)
If you are looking to build it using Resource, look here.
This question is often seen in one of the forum that i hang around. Although the programming language is different, the idea and concept is one. I have already prepared a source code for this project but i will explain a little or less about how it works. Understand that the term stub i am using refers to the application that is going to read a message that has been injected from an application called builder. Be aware that the term injected also refers to implanted or appended. In this article, i will be showing the concept on how a builder and stub works, what will you need before coding it and your preparations as well as pseudocode to ease understanding of the concept. Apart from that you can download the project in case you are not sure what to do with the source code given due to certain complexity.
TCP / IP Sockets in C | eBook
Are you interested in building your own TCP / IP application in C? Learn how to make client server applications such as Instant Messaging or apply TCP / IP onto your existing system for further benefit. By mastering the skills of using sockets in C, you can develop applications that uses the FTP as well as SMTP protocol. To send email or to connect to your own FTP server as well as searching through Google. The possibility for using sockets are unlimited! TCP / IP Sockets in C Practical Guide For Programmers written by Michael J. Donahoo and Kenneth L. Calvert is a good book to start with. By assuming that you have the basics of C programming, it helps you to master the Winsock functions. At the end of the day, you will be able to create multi-threaded server that accepts multiple connections at a time. Apart from that it also gives a brief example of source code for writing a client server using the UDP protocol.
Be reminded that it is TCP / IP for C which means that it is fully focused on C. However there is a small chapter at the end which gives a guidance in C++. This book is the best book you can get to jump start your programming skills in handling sockets in C! Even if you have already learnt sockets, it is a good idea to check the source codes that are taught as their way of coding gives a proper idea on how you should write them well.
Click here to download.
Binary to Hex Converter
This source code below converts a text file with binaries into a text file with hexadecimals. Imagine we have a file of binaries called "hello.bin", we are going to convert it into hexadecimals and write it into a file called "hello.com".
hello.bin
[code]
10110100 00001001
10111010 00001001 00000001
11001101 00100001
11001101 00100000
01101000 01100101 01101100 01101100 01101111 00100100
[/code]
Concept (in terms of ASM)
[code]
mov ah,09
mov dx,0109
int 21
int 20
db "hello$"
[/code]
hello.com
[code]
B4 09 BA 09 01 CD 21 CD 20 68 65 6C 6C 6F 24
[/code]
where you can see how the binaries, hexadecimals and ASM are linked.
[code]
10110100 = B4 = mov ah
00001001 = 09 = 09
[/code]
What "hello.com" does when ran is it prints the word "hello" and exits. Generally this code is a converter but it has given me a further insight of what assembly would look like and how the machine language works now. The source code is as below and it is done in C language (but you would need to write the filename as .cpp instead of .c since the program was not programmed according the C proper structure whereby it should be defining variables before statements).
Source code
[code]
#include <stdio.h>
#include <stdlib.h>
void help(char* fname) {
printf(
"Code programs in binary - by Jakash3\n"
"Usage: %s outfile infile"
"Notes:\n"
" infile = Text file containing ascii 1's and 0's.\n"
" 8 bits per byte, all other characters\n"
" and whitespace ignored.\n"
" outfile = Name of program to create and write to.\n",
fname
);
exit(1);
}
int main(int argc, char** argv) {
if (argc!=3) help(argv[0]);
FILE *dst, *src;
dst = fopen(argv[1],"wb");
if (!dst) { printf("Could not create or truncate %s\nQuitting...",argv[1]); return 1;}
src = fopen(argv[2],"r");
if (!src) { printf("Could not open %s\nQuitting...",argv[2]); return 1;}
char c, byte=0;
int i=0, count=0;
while (!feof(src)) {
if (i==8) { fwrite(&byte,1,1,dst); byte=0; i=0; count++; }
fread(&c,1,1,src);
switch (c) {
case '1':
byte |= ((c=='1') << (7-i));
case '0':
i++;
}
}
fclose(src);
if (!fclose(dst))
printf("Wrote %d bytes to %s\n",count,argv[1]);
return 0;
}
[/code]
Download binary (.exe).
This code was written by jakash3 from Leetcoders.org
* Original link here.
Rootkits | Subverting the Windows Kernel
Are you a programmer that loves to design malicious application? Do you find malicious applications that you have made are easily detected by anti-virus software (oh come on, Fully Un-detectable (FUD) isn't going to last long)? Do you know the difference of user and kernel space? Ever wanted to be able to stay on the same level as the anti-virus as well as getting rid of it?
Take yourself into a whole new level by learning how to develop a rootkit!
Microsoft Detours
Detours is a library for instrumenting arbitrary Win32 functions on x86, x64, and IA64 machines. Detours intercepts Win32 functions by rewriting the in-memory code for target functions. The Detours package also contains utilities to attach arbitrary dynamic-link libraries (DLLs) and data segments (called payloads) to any Win32 binary.
Reading and Writing registry in Windows using WinAPI
For those that are interested in contacting the windows registry via C, here's a list of WinAPI functions that you need to know.
MuteX | How to create a single instance application in C
[code]
#include <windows.h>
#include <stdio.h>
#define MUTEX_NAME "mutex name here, anyname"
int main()
{
HANDLE hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, MUTEX_NAME);
if(hMutex == NULL)
{
// no duplicate instances found
hMutex = CreateMutex(NULL, FALSE, MUTEX_NAME);
}
else
{
// a duplicate was found
return 0;
}
printf("Created console\n");
getchar();
return 1;
}
[/code]
As you can see, there's OpenMuteX and CreateMuteX function that has been used. To briefly explain this, OpenMuteX opens a handle to check whether a mutex has been created. If it returns the value NULL, it means that no mutex of the current string has been created. So when it is NULL, CreateMuteX is called to create the mutex with the string MUTEX_NAME that has been defined. Leave a feedback if you feel that there's lack of information.
Black Hole | Create pixel on the desktop and expand
[code]
#include <windows.h>
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
HDC hDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
POINT pCurPos;
RECT rRect;
HBRUSH hBrush = (HBRUSH)(CreateSolidBrush(RGB(0, 0, 0)));
int iConst = 1;
for( ; ; Sleep(1000))
{
if (GetAsyncKeyState(VK_ESCAPE) != 0)
break;
iConst += 3;
GetCursorPos(&pCurPos);
rRect.left = pCurPos.x - iConst;
rRect.top = pCurPos.y - iConst;
rRect.right = pCurPos.x + iConst;
rRect.bottom = pCurPos.y + iConst;
FillRect(hDC, &rRect, hBrush);
}
DeleteDC(hDC);
return EXIT_SUCCESS;
}
[/code]
I'm not sure where i got this a year ago but generally this code create a black pixel on your desktop. It will terminate only if you press ESCAPE which is detected by GetAsyncKeyState.
Caesar and Rot Cipher Source Code
Ever wanted a portable caesar cipher and decipher at one go? At the end of this post you will find the binary as well as the source code (built in C) for the application. Below is an image of the application testing on "abcdefgh" text. At [+13] you can see that it is equivalent to ROT13 cipher. For those that are familiar with command line, use application.exe "text here".
[code]
/*
* url: http://genesisdatabase.wordpress.com
* email: genesisdatabase@gmail.com
*
* This source code is free to be used by any programmers
* Source code converts all uppercase to lowercase during decryption
* Supports command line usage, use text as argument eg. crack.exe "abcdef"
*/
#include <stdio.h>
#include <string.h>
//#include <stdlib.h> /*include if using system()*/
void DecryptCaesar(char *Encrypted)
{
char i;
int j;
Encrypted = strlwr(Encrypted); /*supports only lowercase*/
//system("REM"); /*use this to copy paste in windows*/
printf(" Caesar Cipher\n\n");
for(i = 0 ; i < 27 ; i++)
{
printf(" [+%d]\t", i);
for(j = 0 ; j < (signed)strlen(Encrypted) ; j++)
{
if(Encrypted[j] == ' ')
printf(""); /*replace "" with " " if you prefer to preserve spacing*/
else if(Encrypted[j] < 'a' || Encrypted[j] > 'z')
printf("%c", Encrypted[j]); /*preserved non-alphabets*/
else if(Encrypted[j] + i > 'z')
printf("%c", Encrypted[j] + i - 26);
else
printf("%c", Encrypted[j] + i);
}
if(i == 13)
printf(" (ROT)");
printf("\n");
if(i == 25)
{
printf(" ");
for(j = 0 ; j < (signed)strlen(Encrypted) + 8 ; j++)
printf("-");
printf("\n");
}
}
printf("\n");
}
int main(int argc, char **argv)
{
char string[64 +1] = {'\0'};
if(argc == 2)
{
strncpy(string, argv[1], 64);
printf("\n");
DecryptCaesar(string);
return 0;
}
for( ; ; )
{
printf("\n Enter a text to encrypt/decrypt (EXIT to quit): ");
fflush(stdin); /*windows*/
//fpurge(stdin); /*linux*/
scanf("%64[^\n]", string);
if(string[0] == 'E' && string[1] == 'X' && string[2] == 'I' && string[3] == 'T' && string[4] == '\0')
break;
printf("\n\n");
DecryptCaesar(string);
}
printf("\n Thanks for using...\n");
return 0;
}
[/code]
Download Binary
Download Source Code
GDWS | GenesisDatabase WLM Stealer
GDWS is an application that i have created using C without relying on resources for its GUI. It's simple to use and requires no driver reliability however it only works on Windows only.
Functions
- GUI in C
- retrieve stored WLM passwords
- run website in a hidden window via IE or FF (using socket)
- intermediate socket usage
- socket to load website
Download
Download Binary
Download Source Code
Note: If anyone requests for the source code, it would be generous of you to direct them here. I know it will consume your time but i'm sure a good deed is always worth it - what comes around goes around.