Wednesday, October 30, 2024

Using gdb

Using gdb


I figured I'll write a mini-tutorial on how to use gdb, because there's not that many places where they teach you how to use gdb effectively.


Let's say you have a program and it crashes, what do you do?


Example code:


```


void func() { char *p = 0; *p = 0x69; }


int main() { func(); }



```



Next:


```


gdb a.out


```



Followed by the `run` command:


```


(gdb) run

Starting program: /home/d/a.out

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".


Program received signal SIGSEGV, Segmentation fault.

0x000055555555513d in func () at test.c:1

1 void func() { char *p = 0; *p = 0x69; }

(gdb)



```



You can see where it crashes, but you'd like a stacktrace...


```


gdb) bt

#0 0x000055555555513d in func () at test.c:1

#1 0x0000555555555155 in main () at test.c:3

(gdb)



```


(NB: `bt` stands for backtrace)


You can go up a frame and check local variables:


```


(gdb) up

#1 0x0000555555555155 in main () at test.c:3

3 int main() { func(); }

(gdb) info local

No locals.



```



Or down a frame and check local variables:


```


(gdb) down

#0 0x000055555555513d in func () at test.c:1

1 void func() { char *p = 0; *p = 0x69; }

(gdb) info local

p = 0x0



```




You can continue after the segfault:


```

(gdb) cont

Continuing.


Program terminated with signal SIGSEGV, Segmentation fault.

The program no longer exists.

(gdb)



```



Now we can re-run it, but before we do, we can set a breakpoint:


```

(gdb) break func

Breakpoint 1 at 0x555555555131: file test.c, line 1.

(gdb)



```



Now we run it again, it will stop at the breakpoint:


```


(gdb) run

Starting program: /home/d/a.out

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".


Breakpoint 1, func () at test.c:1

1 void func() { char *p = 0; *p = 0x69; }

(gdb)


```


We can single step through it:


```


(gdb) step


Program received signal SIGSEGV, Segmentation fault.

0x000055555555513d in func () at test.c:1

1 void func() { char *p = 0; *p = 0x69; }

(gdb)


```



We can also try the command `next`, which is similar to `step` but skips over subroutines.


We can get help from gdb at any time using `help`.


Another useful `info` command is `info reg`, which shows CPU registers.


Also useful is `disas` command, which disassembles the code.

 

Tuesday, October 29, 2024

More Captain Drone Killer ideas...

More Captain Drone Killer ideas...

 

Disclaimer: These are just ideas, use them at your own risk.


Some interesting DIY wide-band jammers


A wide-band jammer that only costs $120 to make:


https://eee.yasar.edu.tr/wp-content/uploads/2015/06/cem_anil_kivanc_jammer_poster_yasar.pdf


Another wide-band jammer, this one uses a spark to generate noise. It's very interesting, but I would be scared of all the x-rays being generated from the spark:


https://www.instructables.com/Simple-broadband-jammer/


And of course, I've seen alot of wide-band jammers for sale. I can't recommend any, since I haven't personally tried them out.


These wide-band jammers would obviously be useful for knocking out drones. Unless you want to use a Microwave Oven Cannon(TM).


Microwave Oven Cannon(TM)


This one is quite simple. If you dismantle your microwave oven and take out the magnetron, waveguide and the electronics, you could turn it into a Microwave Oven Cannon(TM).


I wouldn't recommend it, unless you re-design the waveguide so that it is more of a parabolic dish, so that it projects all the waves in a parallel line.


Speaking of which... drone jamming isn't all that difficult?

It seems drone jamming and knocking out drones isn't all that difficult.


It might be that drone detection is more difficult, because the cellular mobile frequency range is being used by mobile phones as well as drones (drones with SIM cards).


Drone detection, various ways...


  • Radar
    • Hard, because drones are so small you could mistaken them for birds
  •  Microphone
    • Easier than radar, cause they make a buzzing noise
  • Camera
    • Easiest, if you have a fish-eye wide-angle lens with computer vision algorithms
  • Radio Frequency (RF) usage, e.g. cellular frequencies, normal RC (radio controller) frequencies, WiFi frequencies
    • Hard, because it's hard to distinguish normal cellular and WiFi usage from drone usage




Monday, October 14, 2024

Chuck Norris

Chuck Norris


Chuck Norris is such an elite hacker, that when he looks at his smartwatch, the time is always 13:37.

Summary of wavelets

Summary of wavelets https://en.wikipedia.org/wiki/Wavelet_transform https://en.wikipedia.org/wiki/Discrete_wavelet_transform Read the 2nd UR...