Jump to content

Hiding programs in pixels


Prosper

Recommended Posts

Computer and Console seemed only to have to do with games , same for developer corner. So I think this would be the better forum because the program(s) i share is not a game, but can certaintly take apps and put them into pixels.

 

http://i.imgur.com/wkbDL.png

wkbDL.png

 

I wrote a program. That converts a program's bytes. Into pixel values. I wrote a program. That is also the same program that deconverts program's bytes... into a program.

 

An image can store a program.

0 - 255 easily done in a single pixel.

 

1024x1024 image can hold ~1MB of data.

 

We store our programs in pixels. But we can also use any range of 255. Masking ourselves from those antivirus mad men. To hide our programs or not to !

 

Now this has been shared. I share the source. I took a big risk sharing something without googling if others have done it. i like to believe i am special.

#include <Windows.h>
#include "BitmapHelp.h"
#include <GdiPlus.h>
#include <fstream>
using namespace std;
const int imageW = 1024;
const int imageH = 1024;
bool bRunning = false;
BYTE* openBinaryForData(char* filePath, int &byteTotal);
void saveBinaryData(char* filePath, BYTE* fileData, int byteTotal);
void WriteLengthToFile(char* filePath, int nVal);
int ReadLengthFromFile(char* filePath);
void Convert();
void DeConvert();
LRESULT CALLBACK OurWindowProcedure(HWND han_Wind,UINT uint_Message,WPARAM parameter1,LPARAM parameter2)
{
switch(uint_Message)
{
case WM_KEYDOWN:
 {
  // 1. Convert app to image
  // 2. DeConvert image back to app
  //Convert();
  DeConvert();
  bRunning = false;
  break;
 }
 break;
}
return DefWindowProc(han_Wind,uint_Message,parameter1,parameter2);
}
HWND NewWindow(LPCTSTR str_Title,int int_XPos, int int_YPos, int int_Width, int int_Height)
{
WNDCLASSEX wnd_Structure;
wnd_Structure.cbSize = sizeof(WNDCLASSEX);
wnd_Structure.style = CS_HREDRAW | CS_VREDRAW;
wnd_Structure.lpfnWndProc = OurWindowProcedure;
wnd_Structure.cbClsExtra = 0;
wnd_Structure.cbWndExtra = 0;
wnd_Structure.hInstance = GetModuleHandle(NULL);
wnd_Structure.hIcon = NULL;
wnd_Structure.hCursor = NULL;
wnd_Structure.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
wnd_Structure.lpszMenuName = NULL;
wnd_Structure.lpszClassName = "WindowClassName";
wnd_Structure.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
RegisterClassEx(&wnd_Structure);
return CreateWindowEx(WS_EX_CONTROLPARENT, "WindowClassName", str_Title, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE, int_XPos, int_YPos, int_Width, int_Height, NULL, NULL, GetModuleHandle(NULL), NULL);
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreviousInstance,LPSTR lpcmdline,int nCmdShow)
{
using namespace Gdiplus;
HWND han_Window = NewWindow("ImageTest", 100,100, imageW, imageH);
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
bRunning = true;
MSG msg_Message;
while(bRunning == true)
{
 if(PeekMessage(&msg_Message,han_Window,0,0,PM_REMOVE))
 {
  DispatchMessage(&msg_Message);
 }
}
GdiplusShutdown(gdiplusToken);
DestroyWindow(han_Window);
return 0;
}
BYTE* openBinaryForData(char* filePath, int& byteTotal)
{
BYTE* pData;
ifstream inf(filePath, ios::in | ios::binary);
inf.seekg(0, ios::end);
int nLength = inf.tellg();
pData = new BYTE[nLength];
inf.seekg(0, ios::beg);
inf.read((char*)pData, nLength);
inf.close();
byteTotal = nLength;
return pData;
}
void saveBinaryData(char* filePath, BYTE* fileData, int byteTotal)
{
ofstream ofs(filePath, ios::out | ios::binary);
ofs.clear();
for (int iii = 1; iii < byteTotal; ++iii)
{
 ofs.put(fileData[iii]);
}
ofs.close();
}

void Convert()
{
using namespace Gdiplus;
HWND hwnd = FindWindow("WindowClassName", "ImageTest");
HDC hdc = GetDC(hwnd);
// Begin get binary executable bytes
int byteTotal = 0;
BYTE* pBinaryData = openBinaryForData("test.exe", byteTotal);
WriteLengthToFile("linfo.txt", byteTotal);
// End get binary executable bytes


HDC hdcMem = CreateCompatibleDC(hdc);
BYTE* pBits = 0;
HBITMAP hBmp = CreateCompatibleBitmap(hdc, imageW, imageH);

SelectObject(hdcMem, hBmp);
COLORREF colorBG = RGB(0, 255, 255);
FloodFill(hdc, 0, 0, colorBG);
FloodFill(hdcMem, 0, 0, colorBG);
// Copy over bytes to pixels
int Row = 0;
int Col = 0;
for (int iii = 0; iii < byteTotal; ++iii)
{
 BYTE b = pBinaryData[iii];
 COLORREF color = RGB(b, 0, 0);
 ++Row;
 if (Row == imageW) {
  Row = 0;
  ++Col;
 }
 SetPixel(hdcMem, Row, Col, color);
}
BitBlt(hdc, 0, 0, imageW, imageH, hdcMem, 0, 0, SRCCOPY);

PBITMAPINFO bmi = 0;
bmi = CreateBitmapInfoStruct(hwnd, hBmp);
CreateBMPFile(hwnd, "TestImage.bmp", bmi, hBmp, hdc);

DeleteObject(hBmp);
ReleaseDC(hwnd, hdcMem);
ReleaseDC(hwnd, hdc);

delete [] pBinaryData;



MessageBox(0, "ConvertToImage", "Done", MB_OK);
}
void DeConvert()
{
using namespace Gdiplus;
HWND hwnd = FindWindow("WindowClassName", "ImageTest");
HDC hdc = GetDC(hwnd);

Bitmap* bmp = new Bitmap(L"TestImage.bmp", true);
BYTE* pData = new BYTE[imageW * imageH];
int nToWrite = 0;
int row = 0;
int col = 0;
nToWrite = ReadLengthFromFile("linfo.txt");

for (int iii = 0; iii < imageW * imageH; ++iii)
{
 Gdiplus::Color colour;
 bmp->GetPixel(row, col, &colour);

 pData[iii] = colour.GetRed();
 BYTE rVal = pData[iii];

 ++row;
 if (row == imageW) {
  row = 0;
  ++col;
 }
}

nToWrite = nToWrite + 1;
saveBinaryData("test.exe", pData, nToWrite);
ReleaseDC(hwnd, hdc);
MessageBox(0, "DeconvertToBinary", "done", MB_OK);
delete bmp;
delete [] pData;
}
void WriteLengthToFile(char* filePath, int nVal)
{
ofstream ofs(filePath, ios::out);
ofs.clear();
ofs << nVal;
ofs.close();
}
int ReadLengthFromFile(char* filePath)
{
int nVal = 0;
ifstream inf(filePath, ios::in);
inf >> nVal;
inf.close();
return nVal;
}

?I compile the program for you. With optin to deconvert on, press a key it will create the gw.setup.exe.

?

?ImageTest.exe. (I press l in window one opened, any key would probably do)

?I use multibyte character set . no angry please.

?

The Deconverter (pixels/image to app)

?http://www.sendspace.com/file/okajzc

?Contents

?The program

?The image for guild wars setup

?a tex t file dtailing how large the exeuctable for guild wars is suppose to be.

The converter (app to image/pixels)

http://www.sendspace.com/file/nyx4gk

Contents

The program

test.exe (gw setup)

redacted

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...