pwnable.kr first question FD

Topics address http://pwnable.kr/play.php

The first question FD

Environment is kali system

First, open the topic

Follow the prompts to connect ssh password for the guest

View the contents of the documents found flag file, but does not have read permission

View fd.c code file

Review function appears

int argc parameters to be entered

char * argv [] indicates the parameters including the filename, the file name is argv [0]

char * envp [] is an environment variable, such as path = c: \ windows or something like that. It is not an integer which is count [i] == NULL is represented by the end of the last evnp

atoi () ; atoi () function string str scan parameters, skip over whitespace characters (e.g., space, tab indents, () function detected by isspace becomes), or until the number meets the sign began do the conversion, but then encountered the end of the non-numeric or string ( '\ 0') before the end of the conversion, and returns the results.

read (a, b, c) ; stdio function a is 0 there are three types of standard input standard output when a read error reading output 2, b and c is a variable number of bytes

Example: read (0, buf, 32) is the input to the 32 bytes buf 'in

strcmp (a, b) comparing the value of ab if a == b returns 0 a> b returns a positive number a <b returns a negative

The goal is to achieve: system ( "/ bin / cat flag")

First argc can not <2 otherwise directly out of the

Analysis of the code must first meet strcmp ( "LETMEWIN \ n", buf) == 0;

fd = 0 then the input LETMEWIN \ n

I.e., argv [1] == 0x1234 = 4660

Get flag

Guess you like

Origin www.cnblogs.com/mouzaisi/p/12177817.html