user:mp010784:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:mp010784:start [2016/04/28 15:40] – mp010784 | user:mp010784:start [2016/05/12 13:18] (current) – [Installing and Setting up a Samba Server] mp010784 | ||
---|---|---|---|
Line 53: | Line 53: | ||
{{youtube> | {{youtube> | ||
+ | |||
+ | ====Summer of code 2016 plans and shared tmux sessions==== | ||
+ | After seeing this semester' | ||
+ | {{https:// | ||
+ | |||
+ | Also Tyler and my project, the manage script, located here on github: {{https:// | ||
+ | |||
+ | Tyler and I were talking about keeping our coding chops sharp this summer by working together on something over the summer. | ||
+ | <cli> | ||
+ | $ telnet spoonbomb.com | ||
+ | </ | ||
+ | into my server but Im not sure if I have new user registration set up right and I don;t even know imost of the configuration settings so I;m going to have to look into it. | ||
+ | |||
+ | Another thing Tyler and I want to do over the summer is assuming that I get the prize money for winnign teh Sustainability Fair thing, then I know we both were gonna pick up some Raspberry Pi's adn Tyler mentioned an interest in learning some Python programming to go with it, I have some exposure to python from before I came back to CCC but I'm pretty stale with it so we both might venture down that path too over the summer. | ||
+ | |||
+ | So Tyler and I made a repository to work on our summer coding at {{https:// | ||
+ | |||
+ | I also successfully got us to share a regular tmux session which I had attempted to do earlier in the semester unsuccessfully but I think it was because I made the socket in my own personal home directory as in this case I put it someplace neutral like /tmp folder. | ||
+ | |||
+ | So to do this I created a new tmux session with in /tmp called par with:\\ | ||
+ | <cli> | ||
+ | tmux -S /tmp/pair | ||
+ | </ | ||
+ | |||
+ | Which immediately puts me in the newly created tmux session which I have to extend the persmissions on for Tyler and I to share the session, so I run:\\ | ||
+ | <cli> | ||
+ | sudo chmod 777 /tmp/pair | ||
+ | </ | ||
+ | |||
+ | Tyler also has to have a valid account on the machien which I made one called nullist as he wanted on my webserver for him. I also have the tendency to use a couple lines on my / | ||
+ | <cli> | ||
+ | PermitRootLogin no | ||
+ | AllowUsers robgraves | ||
+ | </ | ||
+ | so I had to add Tyler to the whitelisted users like:\\ | ||
+ | <cli> | ||
+ | PermitRootLogin no | ||
+ | AllowUsers robgraves nullist | ||
+ | </ | ||
+ | Then I had to restart the ssh daemon, which depending on which machine I did it on was either:\\ | ||
+ | <cli> | ||
+ | sudo service ssh restart | ||
+ | </ | ||
+ | Or:\\ | ||
+ | <cli> | ||
+ | sudo /etc/init.d ssh restart | ||
+ | </ | ||
+ | Then Tyler can now login remotely over ssh by using the command, being that I'm using a much higher port number than ssh's default 22 you have to specify it as such like:\\ | ||
+ | <cli> | ||
+ | ssh nullist@www.spoonbomb.com -p PORTNUMBER | ||
+ | </ | ||
+ | The general form for ssh' | ||
+ | <cli> | ||
+ | ssh USERNAME@HOSTNAMEorIPADDRESS -p PORTNUMBER | ||
+ | </ | ||
+ | After that Tyler was securely logged into my machine, all he needed to do then was attach to the previously created tmux socket that was put in a neutral location and opened up permissions with:\\ | ||
+ | <cli> | ||
+ | tmux -S /tmp/pair attach | ||
+ | </ | ||
+ | Now we both had control over the same terminal and we coudl also chat over the terminal as is refelected by my bash history...probably not the best way to communicate, | ||
+ | |||
+ | ==== Playing around with GDB==== | ||
+ | |||
+ | After taking Data Structures I wanted to learn more about gdb and I went out seeking books or websites that taught how to use gdb in more detail. | ||
+ | |||
+ | One fo the first things this book had me do was create a Hello World program with a loop in C as seen below:\\ | ||
+ | |||
+ | < | ||
+ | #include < | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | int i; | ||
+ | for(i=0; | ||
+ | { | ||
+ | printf(" | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Then we compile the code with debugging symbols:\\ | ||
+ | |||
+ | <cli> | ||
+ | gcc -g firstprog.c | ||
+ | </ | ||
+ | |||
+ | which creates the executable a.out file which when run generates on the command line the output:\\ | ||
+ | |||
+ | <cli> | ||
+ | ╭─robgraves@arrakis ~ | ||
+ | ╰─➤ | ||
+ | ╭─robgraves@arrakis ~ | ||
+ | ╰─➤ | ||
+ | ╭─robgraves@arrakis ~ | ||
+ | ╰─➤ | ||
+ | Hello, World! | ||
+ | Hello, World! | ||
+ | Hello, World! | ||
+ | Hello, World! | ||
+ | Hello, World! | ||
+ | Hello, World! | ||
+ | Hello, World! | ||
+ | Hello, World! | ||
+ | Hello, World! | ||
+ | Hello, World! | ||
+ | ╭─robgraves@arrakis ~ | ||
+ | ╰─➤ | ||
+ | </ | ||
+ | |||
+ | Then you can load up the program in gdb using the -q option to suppress all the startup messages from gdb:\\ | ||
+ | |||
+ | <cli> | ||
+ | gdb -q ./a.out | ||
+ | </ | ||
+ | |||
+ | which should bring us to a gdb prompt that looks like:\\ | ||
+ | |||
+ | <cli> | ||
+ | (gdb) | ||
+ | </ | ||
+ | |||
+ | Then we run:\\ | ||
+ | <cli> | ||
+ | (gdb)list | ||
+ | </ | ||
+ | |||
+ | which shows us the code in our program and then run disassemble main:\\ | ||
+ | |||
+ | <cli> | ||
+ | disassemble main | ||
+ | </ | ||
+ | |||
+ | which shows us the assembly for our code for this build. | ||
+ | |||
+ | < | ||
+ | #~/.gdbinit | ||
+ | |||
+ | set disassembly intel | ||
+ | #set disassembly att | ||
+ | </ | ||
+ | |||
+ | which this is actually all that I have in my .gdbinit file.\\ | ||
+ | |||
+ | The resulting output from the list commadn and disassemble main in gdb appears as:\\ | ||
+ | |||
+ | < | ||
+ | (gdb) list | ||
+ | 1 #include < | ||
+ | 2 | ||
+ | 3 int main() | ||
+ | 4 { | ||
+ | 5 int i; | ||
+ | 6 for(i=0; i < 10; i++) | ||
+ | 7 { | ||
+ | 8 printf(" | ||
+ | 9 } | ||
+ | 10 } | ||
+ | (gdb) disassemble main | ||
+ | Dump of assembler code for function main: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | End of assembler dump. | ||
+ | (gdb) | ||
+ | </ | ||
+ | |||
+ | Now we set a breakpoint at main by running:\\ | ||
+ | |||
+ | <cli> | ||
+ | break main | ||
+ | </ | ||
+ | |||
+ | then we run the program with:\\ | ||
+ | |||
+ | <cli> | ||
+ | run | ||
+ | </ | ||
+ | |||
+ | At this point the book tells me to run (gdb)info register eip , which ends up spitting an error stating invalid register " | ||
+ | |||
+ | So then I run from my machine with the discrepency solved:\\ | ||
+ | <cli> | ||
+ | (gdb)info register rip | ||
+ | </ | ||
+ | |||
+ | Which works and gives me the info in the current instruction pointer register which looks like this:\\ | ||
+ | |||
+ | < | ||
+ | (gdb) run | ||
+ | Starting program: / | ||
+ | |||
+ | Breakpoint 1, main () at firstprog.c: | ||
+ | 6 for(i=0; i < 10; i++) | ||
+ | (gdb) info register eip | ||
+ | Invalid register `eip' | ||
+ | (gdb) info register rip | ||
+ | rip 0x400535 0x400535 < | ||
+ | (gdb) | ||
+ | </ | ||
+ | |||
+ | A shortcut for this command is "i r rip" for "info register rip" in addition we can examine the given address. | ||
+ | |||
+ | <cli> | ||
+ | (gdb) info register rip | ||
+ | rip 0x400535 0x400535 < | ||
+ | (gdb) i r rip | ||
+ | rip 0x400535 0x400535 < | ||
+ | (gdb) x/o 0x400535 | ||
+ | 0x400535 < | ||
+ | (gdb) x/o $rip | ||
+ | 0x400535 < | ||
+ | (gdb) x/x $rip | ||
+ | 0x400535 < | ||
+ | (gdb) x/u $rip | ||
+ | 0x400535 < | ||
+ | (gdb) x/t $rip | ||
+ | 0x400535 < | ||
+ | (gdb) x/2x | ||
+ | 0x400539 < | ||
+ | (gdb) x/2x $rip | ||
+ | 0x400535 < | ||
+ | (gdb) x/12x $rip | ||
+ | 0x400535 < | ||
+ | 0x400545 < | ||
+ | 0x400555: | ||
+ | (gdb) | ||
+ | </ | ||
+ | |||
+ | We can also examine the info by b for a single byte, h for a halfword which is two bytes, or w for a word, or g for a giant which is 8 bytes:\\ | ||
+ | |||
+ | <cli> | ||
+ | (gdb) x/8xb $rip | ||
+ | 0x400535 < | ||
+ | (gdb) x/8xh $rip | ||
+ | 0x400535 < | ||
+ | (gdb) x/8xw $rip | ||
+ | 0x400535 < | ||
+ | 0x400545 < | ||
+ | (gdb) | ||
+ | </ | ||
+ | |||
+ | You can also go on to examine the instructions at the register with x/i or multiples say with x/3i:\\ | ||
+ | |||
+ | <cli> | ||
+ | (gdb) x/i $rip | ||
+ | => 0x400535 < | ||
+ | (gdb) x/3i $rip | ||
+ | => 0x400535 < | ||
+ | | ||
+ | | ||
+ | (gdb) x/7xb $rip | ||
+ | 0x400535 < | ||
+ | (gdb) x/i $rip | ||
+ | => 0x400535 < | ||
+ | (gdb) | ||
+ | </ | ||
+ | |||
+ | The book has me play around with some of the info at the registers a little more, most notibly is the nexti command which seems to move to the next instruction: | ||
+ | |||
+ | <cli> | ||
+ | (gdb) x i rbp | ||
+ | A syntax error in expression, near `rbp'. | ||
+ | (gdb) i r rbp | ||
+ | rbp 0x7fffffffe5e0 0x7fffffffe5e0 | ||
+ | (gdb) x/4xb $rbp - 4 | ||
+ | 0x7fffffffe5dc: | ||
+ | (gdb) x/4xb 0x7fffffffe5dc | ||
+ | 0x7fffffffe5dc: | ||
+ | (gdb) print $rbp -4 | ||
+ | $1 = (void *) 0x7fffffffe5dc | ||
+ | (gdb) x/4xb $1 | ||
+ | 0x7fffffffe5dc: | ||
+ | (gdb) x/xw $1 | ||
+ | 0x7fffffffe5dc: | ||
+ | (gdb) nexti | ||
+ | 0x000000000040053c 6 | ||
+ | (gdb) x/4xb $1 | ||
+ | 0x7fffffffe5dc: | ||
+ | (gdb) x/dw $1 | ||
+ | 0x7fffffffe5dc: | ||
+ | (gdb) i r rip | ||
+ | rip 0x40053c 0x40053c < | ||
+ | (gdb) x/i $rip | ||
+ | => 0x40053c < | ||
+ | (gdb) x/10i $rip | ||
+ | => 0x40053c < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | (gdb) | ||
+ | </ | ||
+ | |||
+ | Then moving further along in the intructions: | ||
+ | |||
+ | <cli> | ||
+ | (gdb) nexti | ||
+ | 0x000000000040054c 6 | ||
+ | (gdb) x/i $rip | ||
+ | => 0x40054c < | ||
+ | (gdb) nexti | ||
+ | 0x0000000000400550 6 | ||
+ | (gdb) x/i $rip | ||
+ | => 0x400550 < | ||
+ | (gdb) nexti | ||
+ | 8 printf(" | ||
+ | (gdb) i r rip | ||
+ | rip 0x40053e 0x40053e < | ||
+ | (gdb) x/2i $rip | ||
+ | => 0x40053e < | ||
+ | | ||
+ | (gdb) | ||
+ | </ | ||
+ | |||
+ | Then we look at the stack pointer at rsp register:\\ | ||
+ | |||
+ | <cli> | ||
+ | (gdb) i r rdi | ||
+ | rdi 0x1 1 | ||
+ | (gdb) i r rsp | ||
+ | rsp 0x7fffffffe5d0 0x7fffffffe5d0 | ||
+ | (gdb) x/2xw 0x4005e4 | ||
+ | 0x4005e4: | ||
+ | (gdb) x/6xb 0x4005e4 | ||
+ | 0x4005e4: | ||
+ | (gdb) x/6ub 0x4005e4 | ||
+ | 0x4005e4: | ||
+ | (gdb) | ||
+ | </ | ||
+ | |||
+ | The above 6 units in hex or in decimal are the ASCII values for " | ||
+ | |||
+ | <cli> | ||
+ | (gdb) x/6cb 0x4005e4 | ||
+ | 0x4005e4: | ||
+ | (gdb) x/s 0x4005e4 | ||
+ | 0x4005e4: | ||
+ | (gdb) | ||
+ | </ | ||
+ | |||
+ | And we continue on:\\ | ||
+ | |||
+ | <cli> | ||
+ | (gdb) x/2i $rip | ||
+ | => 0x40053e < | ||
+ | | ||
+ | (gdb) x/xw $rip | ||
+ | 0x40053e < | ||
+ | (gdb) nexti | ||
+ | 0x0000000000400543 8 | ||
+ | (gdb) x/xw $esp | ||
+ | 0xffffffffffffe5d0: | ||
+ | (gdb) x/xw $rsp | ||
+ | 0x7fffffffe5d0: | ||
+ | (gdb) x/i rip | ||
+ | No symbol " | ||
+ | (gdb) x/i $rip | ||
+ | => 0x400543 < | ||
+ | (gdb) nexti | ||
+ | Hello, World! | ||
+ | 6 for(i=0; i < 10; i++) | ||
+ | (gdb) x/2i $rip | ||
+ | => 0x400548 < | ||
+ | | ||
+ | (gdb) | ||
+ | </ | ||
+ | |||
+ | I'm gonna pretty much end here as this is where I'm starting to trail off, but I found doing this to be interesting and want to keep digging down this rabbit hole.\\ | ||
+ | |||
+ | <cli> | ||
+ | (gdb) nexti | ||
+ | 0x0000000000400543 8 | ||
+ | (gdb) x/xw $esp | ||
+ | 0xffffffffffffe5d0: | ||
+ | (gdb) x/xw $rsp | ||
+ | 0x7fffffffe5d0: | ||
+ | (gdb) x/i rip | ||
+ | No symbol " | ||
+ | (gdb) x/i $rip | ||
+ | => 0x400543 < | ||
+ | (gdb) nexti | ||
+ | Hello, World! | ||
+ | 6 for(i=0; i < 10; i++) | ||
+ | (gdb) x/2i $rip | ||
+ | => 0x400548 < | ||
+ | | ||
+ | (gdb) x/i $rip | ||
+ | => 0x400548 < | ||
+ | (gdb) x/dw $eax | ||
+ | 0xe: Cannot access memory at address 0xe | ||
+ | (gdb) x/dw $rax | ||
+ | 0xe: Cannot access memory at address 0xe | ||
+ | (gdb) x/dw $rbp | ||
+ | 0x7fffffffe5e0: | ||
+ | (gdb) nexti | ||
+ | 0x000000000040054c 6 | ||
+ | (gdb) x/dw $rbp | ||
+ | 0x7fffffffe5e0: | ||
+ | (gdb) x/dw $eax | ||
+ | 0xe: Cannot access memory at address 0xe | ||
+ | (gdb) x/i $rip | ||
+ | => 0x40054c < | ||
+ | (gdb) nexti | ||
+ | 0x0000000000400550 6 | ||
+ | (gdb) x/dw $eax | ||
+ | 0xe: Cannot access memory at address 0xe | ||
+ | (gdb) x/i $rip | ||
+ | => 0x400550 < | ||
+ | (gdb) disass main | ||
+ | Dump of assembler code for function main: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | => 0x0000000000400550 < | ||
+ | | ||
+ | | ||
+ | End of assembler dump. | ||
+ | (gdb) list | ||
+ | 1 #include < | ||
+ | 2 | ||
+ | 3 int main() | ||
+ | 4 { | ||
+ | 5 int i; | ||
+ | 6 for(i=0; i < 10; i++) | ||
+ | 7 { | ||
+ | 8 printf(" | ||
+ | 9 } | ||
+ | 10 } | ||
+ | (gdb) | ||
+ | |||
+ | </ | ||
+ | |||
+ | Maybe over the summer I'll more time to delve into this hacking book abit more and see what else I can experiment with.\\ | ||
Some Old Stuff - Something something dark side.\\ | Some Old Stuff - Something something dark side.\\ |
user/mp010784/start.1461872457.txt.gz · Last modified: 2016/04/28 15:40 by mp010784