Linux / GDB Commands Flashcards

Understand Linux commands that help with gaining info on Linux machines for assembly learning as well as GDB commands

1
Q

What commands can be used to view the system CPU info on Linux?

A

cat proc/cpuinfo or lscpu

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you run a program in GDB on a Linux system?

A
The following syntax runs a program in GDB:
"gdb /bin/bash"
"break main"
"run"
(gdb has started at this point)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What commands allow viewing of registers for a program from Linux GDB?

A

The following will display registers:
“info registers” or “display /x $eax”

“info all-registers” -> (displays ALL registers)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What command disassembles a register?

A

“disassemble $eip” as an example

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What command changes the syntax of a GDB disassembler to Intel syntax?

A

“set disassembly-flavor intel”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you add debug symbols while compiling a program?

A

“gcc -ggdb main.c -o main”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What command displays the functions within a file/program?

A

“info functions”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What command displays all the sources for a file?

A

“info sources”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What command displays the global variables for a file?

A

“info variables”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What command displays the local variables of a function?

A

“info scope function_name”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What command allows you to copy debug symbols from a binary file to a new file?

A

“objcopy –only-keep-debug File_w_symbols New_symbols_file”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What command allows you to remove debug symbols from a binary file?

A

“strip –strip-debug File_w_symbols”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the command strace?

A

Traces system calls made by a program and arguments passed by the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What strace command attaches to a running program?

A

“strace -p [PID]”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to print the statistics for the syscalls in a program?

A

“strace -s Program_Name”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What command traces a specific syscall(s)?

A

“strace -e syscall_name(s)”

17
Q

What are the commands to set breakpoints in GDB?

A

“break [address]”
“break [function name]”
“break [line #}”

18
Q

How can you view the breakpoints previously set?

A

“info breakpoints”

19
Q

How can you examine a specific address?

A

“x/[format letter]”

Ex: x/s (string) 0x80490a4 => “Another World!”

20
Q

What does “stepi” do?

A

It steps through each instruction within the code.

21
Q

What does “step” do?

A

It steps through the code per source line.

22
Q

What command changes the value registers or data within the running code?

A

“set [$eax] = 0xbffff272”

“set argv[1] = D”

23
Q

What are convenience variables commands?

A

“set $demo = 10”
“set argv[1] = $demo”
print argv[1]= 10
call Funtion_name [add argu]

24
Q

What can the command “strings” do?

A

Display strings contained in a program. Maybe useful to discover poorly coded information.

25
Q

What are conditional breaks in GDB?

A

Conditional breaks are used to break only when a condition is met. These are great for loops.