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.
Obfuscation - heard it, learn it!
Obfuscation is the act of rendering virtually anything, not understandable. Code obfuscation is where programmers code in such a way that no other programmers can understand.
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.
Decrypt Firefox 3.5 and 3.6 stored passwords in C | Source Code | Application
If you have already decrypted passwords for Firefox 1, 2 and 3 (if you need them, it's here), here is the source code in C that helps you decrypt Firefox passwords for version 3.5 and 3.6! This source code is written by ZeR0 from HackHound.org. This source code is generally open source by the author but the terms of use is to give credits if you use it.
Download source code here.
Download binary / application 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.
WLM / Firefox / No-IP / DynDNS Recovery in C | Source Code
As mentioned in one of my previous posts i will be releasing the function to retrieve passwords of WLM, Firefox, No-IP and DynDNS.
Download WLM Recovery source code.
Download Firefox Recovery source code.
Download No-IP Recovery source code.
Download DynDNS Recovery source code.
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
MD5 Generator
Well i was working on something which requires this so i guess this would come in handy for anyone that needs it, it accepts text to be encrypted as well as files.
Download
It does not belong to me however it was found on the internet so credits belongs to the owner.
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.
Capturing Desktop Screenshot to File in C
Here's a simple function that helps you dump screenshots into files. By calling CaptureDesktopScreenshotToFile you can simply get the screenshot without dealing with any GDI yourself.
[code]
#include <windows.h>
int main()
{
CaptureDesktopScreenshotToFile("screenshot.bmp");
return 0;
}
[/code]
And here's the code for you.
[code]
#include <windows.h>
PBITMAPINFO CreateBitmapInfoStruct(HBITMAP hBmp);
int CreateBMPFile(LPTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP, HDC hDC);
int CaptureDesktopScreenshotToFile(char *FILENAME)
{
HDC hdcScreen,hdcCompatible;
HBITMAP hbmScreen;
hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);
hdcCompatible = CreateCompatibleDC(hdcScreen);
// Create a compatible bitmap for hdcScreen.
int ScreenWidth = GetDeviceCaps(hdcScreen, HORZRES);
int ScreenHeight = GetDeviceCaps(hdcScreen, VERTRES);
hbmScreen = ::CreateCompatibleBitmap(hdcScreen,ScreenWidth,ScreenHeight);
if(hbmScreen == 0)
return 0;
// Select the bitmaps into the compatible DC
if(!::SelectObject(hdcCompatible, hbmScreen))
return 0;
if(!::BitBlt(hdcCompatible,0,0,ScreenWidth,ScreenHeight,hdcScreen,0,0,SRCCOPY))
return 0;
// Clean Tmp
DeleteFile(FILENAME);
// Take shot
if(CreateBMPFile(FILENAME,CreateBitmapInfoStruct(hbmScreen),hbmScreen,hdcScreen) == 0)
return 0;
// Compression
//bmp2jpeg(DIRECTORY_TMP, DIRECTORY_TMP);
return 1;
}
int CreateBMPFile(LPTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP, HDC hDC)
{
HANDLE hf; // file handle
BITMAPFILEHEADER hdr; // bitmap file-header
PBITMAPINFOHEADER pbih; // bitmap info-header
LPBYTE lpBits; // memory pointer
DWORD dwTotal; // total count of bytes
DWORD cb; // incremental count of bytes
BYTE *hp; // byte pointer
DWORD dwTmp;
pbih = (PBITMAPINFOHEADER) pbi;
lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);
if(!lpBits)
return 0;
// Retrieve the color table (RGBQUAD array) and the bits
// (array of palette indices) from the DIB.
if(!GetDIBits(hDC, hBMP, 0, (WORD) pbih->biHeight, lpBits, pbi, DIB_RGB_COLORS))
return 0;
// Create the .BMP file.
hf = CreateFile(pszFile, GENERIC_READ | GENERIC_WRITE, (DWORD) 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL);
if(hf == INVALID_HANDLE_VALUE)
return 0;
hdr.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M"
// Compute the size of the entire file.
hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) + pbih->biSize + pbih->biClrUsed * sizeof(RGBQUAD) + pbih->biSizeImage);
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
// Compute the offset to the array of color indices.
hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + pbih->biSize + pbih->biClrUsed * sizeof (RGBQUAD);
// Copy the BITMAPFILEHEADER into the .BMP file.
if(!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER),(LPDWORD) &dwTmp, NULL))
return 0;
// Copy the BITMAPINFOHEADER and RGBQUAD array into the file.
if(!WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER) + pbih->biClrUsed * sizeof (RGBQUAD), (LPDWORD) &dwTmp, ( NULL)))
return 0;
// Copy the array of color indices into the .BMP file.
dwTotal = cb = pbih->biSizeImage;
hp = lpBits;
if(!WriteFile(hf, (LPSTR) hp, (int) cb, (LPDWORD) &dwTmp,NULL))
return 0;
// Close the .BMP file.
if(!CloseHandle(hf))
return 0;
// Free memory.
GlobalFree((HGLOBAL)lpBits);
return 1;
}
PBITMAPINFO CreateBitmapInfoStruct(HBITMAP hBmp)
{
BITMAP bmp;
PBITMAPINFO pbmi;
WORD cClrBits;
// Retrieve the bitmap color format, width, and height.
if (!GetObject(hBmp, sizeof(BITMAP), (LPSTR)&bmp))
return NULL;
// Convert the color format to a count of bits.
cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel);
if (cClrBits == 1)
cClrBits = 1;
else if (cClrBits <= 4)
cClrBits = 4;
else if (cClrBits <= 8)
cClrBits = 8;
else if (cClrBits <= 16)
cClrBits = 16;
else if (cClrBits <= 24)
cClrBits = 24;
else cClrBits = 32;
// Allocate memory for the BITMAPINFO structure. (This structure
// contains a BITMAPINFOHEADER structure and an array of RGBQUAD
// data structures.)
if (cClrBits != 24)
pbmi = (PBITMAPINFO) LocalAlloc(LPTR,
sizeof(BITMAPINFOHEADER) +
sizeof(RGBQUAD) * (1<< cClrBits));
// There is no RGBQUAD array for the 24-bit-per-pixel format.
else
pbmi = (PBITMAPINFO) LocalAlloc(LPTR,
sizeof(BITMAPINFOHEADER));
// Initialize the fields in the BITMAPINFO structure.
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biWidth = bmp.bmWidth;
pbmi->bmiHeader.biHeight = bmp.bmHeight;
pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel;
if (cClrBits < 24)
pbmi->bmiHeader.biClrUsed = (1<<cClrBits);
// If the bitmap is not compressed, set the BI_RGB flag.
pbmi->bmiHeader.biCompression = BI_RGB;
// Compute the number of bytes in the array of color
// indices and store the result in biSizeImage.
// For Windows NT, the width must be DWORD aligned unless
// the bitmap is RLE compressed. This example shows this.
// For Windows 95/98/Me, the width must be WORD aligned unless the
// bitmap is RLE compressed.
pbmi->bmiHeader.biSizeImage = ((pbmi->bmiHeader.biWidth * cClrBits +31) & ~31) /8
* pbmi->bmiHeader.biHeight;
// Set biClrImportant to 0, indicating that all of the
// device colors are important.
pbmi->bmiHeader.biClrImportant = 0;
return pbmi;
}
[/code]