Saturday, May 30, 2015

Using RTLSDR with an Android Smartphone

Been away for a while (sorry to my few readers!).  I'm busy a lot so please understand, hopefully good things coming.

This one was very fun, I would like to see more digital modes supported which may happen in the future.

Hardware required:
--Android phone with Android 4.4 or higher
--USB-OTG cable
--RTLSDR dongle and its antenna


I was able to get the USB-OTG cable for ~$4 from Fry's, not hard to get.  Software-wise, you need the RTL2832U driver made by Martin Marinov off Google Play (search those terms on Google Play, the driver is free).  You can pay $10 for an SDR Touch app that does what RF Analyzer (the app we use) does, probably more as I haven't tried it yet; however getting a free app is more fun right?--At least for your wallet. :)

 The app (Github site pictured above), which *can* be free if you just install the .apk off Github ( https://github.com/demantz/RFAnalyzer ), but is now available as well for $1.01 on Google Play (don't ask me about the pricing, maybe he likes pennies :p )  If you want the free route, download the zip file.  Now I did this in Windows so it may be slightly different for Linux/BSD.  On your phone, set the "Developer Options" on and enable "USB Debugging" and allow "Installing apps from unverified places".  It was fairly straight forward from there, I just copied over the "RFAnalyzer.apk" to my phone and it installed and put an icon on my phone.

To use it, first be sure to charge your phone up (I looked for a while for ways to charge the phone while using the USB port, there were some ways to do it but they looked a little risky to me and I don't want to break my phone.  Watch out for the "Y-splitters", that apparently doesn't work so be careful if you find products that say they can charge and have a device plugged in.  So you're limited to your battery-life unless you find another way.).  Oh and note that it's recommended to plug the RTLSDR dongle into a powered USB-hub so it draws power to operate from AC instead of your phone.  Plug in the hardware first, then open up the app and go to settings and set the source type as RTL-SDR.

Other than that, it should do the rest.  Hit the triangle-looking button to "start sampling" and you should start seeing a spectral display.  You can scroll with your fingers through the spectrum.  Now go to the FM-radio bands of 87.5MHz - 108MHz and seek out your favorite radio station.  You may have to set modulation to FM.  If you hear it, it works!  You're actually receiving the waves, not listening through the internet.

Sorry I don't have nice pictures of my setup, I use my phone for most all my pictures now.  Also I did this a while ago and when my phone updated to Android 5.0 the app was slightly broken, so just a warning for that.

Monday, December 1, 2014

Quick FM Radio Receiver with RTL-SDR Dongle, Gqrx, and Kali Linux

This tutorial is an introduction to the RTL-SDR dongle and some hints using it with Gqrx software.  I was able to buy one recently off of Amazon for ~$8-12.  For the amount of functionality you get with this dongle, that is a huge return on investment.  I highly recommend getting one (I may get a few more for different purposes) and get receiving.  Getting up and running is unbelievable simple and fast compared to other ways of connecting computers and radios.

For this tutorial, you need:
--RTL-SDR RTL2832U DVB-T Dongle (these things have a million names, some call them R820T. Mine has frequency range 24MHz-1766MHz) and of course its antenna
--Kali Linux (1.0.6 64-bit) LiveCD running on computer with 4GB RAM with Gqrx software
--Headphones or speakers to listen

1)  Boot up Kali Linux. Attach and setup antenna before plugging into USB port to prevent damaging USB port.  Insert RTL-SDR dongle into a USB port.  Kali should already have drivers needed for it.

2) Open up Gqrx by going to clicking on Applications tab up top, then -> Kali Linux -> Wireless Attacks -> Software Defined Radio -> gqrx.  We aren't doing any attacks here, you can use Gqrx on other Linux distros too if Kali isn't your cup of tea, Kali just happens to be a favorite of mine (I like Debian) to pentest/probe my own computers and network.

3) So Gqrx should auto-detect your dongle, Device should be "Generic RTL2832U SN" then it will be a big number.  Device string "rtl=0".  Sample rate "1500000".  LNB LO "0 MHz".  Audio Output "Default".  Sample rate "48kHz".

All these are default settings, and they work completely fine.  Don't change them unless you know what you're doing; the goal here is to get up and running as quick as possible.

4) Now you can start receiving, no GNU Radio receiver blocks to be made, this is sufficient to receive A LOT.  Click on the little power button below 'File', it should start somewhere around 144MHz (the 2 meter band for Ham radio).

5) Changing the frequency was a little tricky at first, you hover the mouse pointer over frequency number then type in what frequency you want, it then goes to next digit.  So if you're on 143.899.302 MHz and want clean 144.000.000MHz, put your mouse over the 3, type '4', then press 0 until the end.  You can use the mouse to click the frequency and lower it, but I didn't really like that feature.

You can use the mouse to grab the scanner to move it across the bandwidth on the screen (can't scroll across without changing frequency at top, at least haven't figured that out yet).  You can enable "full screen" mode at top near the save button.  On Audio tab on bottom right, main thing is to change the gain (basically volume) or record samples.  You can change the demodulation mode on the right too (main ones are AM, Narrow FM, and Wide FM; USB/LSB is more for HF frequencies which need a special up-converter to receive and same with CW modes).  You can leave the Filter setting at Normal and AGC on Fast, they both "work good"; of course tinker if you desire.  The Squelch and Noise Blanker settings I didn't mess with either as we're doing simple receiving here.

On the FFT settings, you have to be careful, I had the program crash when I was playing around with them.  You can change the color of the waterfall display and fill in the colors.  You can increase averaging so to pinpoint signals even better.  But most importantly, you can increase the Frames per Second (FPS) and the FFT size up to a max of 16384 FFT points being calculated.

##### WARNING #####

You can make the application crash if you crank these settings too high, so it's highly dependent on your system CPU and the RAM.

6) That's mostly it, all the hard work has been done for you, and this is very fun and easy!  Here's a listing of all the signals I was able to receive so far:

--Scattering of AM reception around 25MHz (near lower limit of RTL-SDR), need better antenna for them.
--My car key fob on 313.795MHz with AM, was able to see the quick burst of the protocol.  Will probably have a tutorial on capturing these signals in the future.
--Another van key fob on 307.9MHz with AM, had a weird waveform.
--NOAA weather station for my locality on 162.541MHz on Narrow FM.
--Unidentified signal on 454.3MHz using AM, UHF business band and Family Radio Service "walkie talkies"
--Unidentified signal on 480MHz using AM, TV channels
--Unidentified signal on 869.5MHz using AM, Public safety or commerical 2-way
--Pagers on 931.29MHz using AM, very pronounced signal and can be decoded, haven't done that *yet*
--Unidentified signal on 940.218MHz using AM, commerical 2-way radio
--Unidentified signal on 960MHz using AM, mixed studio-transmitter links

So there is PLENTY to do, just overwhelming amounts of things you can do with this receiver.  Have fun!

Useful Links:
https://wiki.installgentoo.com/index.php?title=Software-defined_radio
www.rtl-sdr.com
www.sigidwiki.com/wiki/Signal_Identification_Guide
gqrx.dk
http://distrowatch.com/?newsid=08246

Making the D-Link FR300 Wifi USB Dongle work in Kali Linux

Remembered I had this wifi USB dongle, and it wouldn't work before on my Linux systems, I believe it is primarily intended for Windows PC's.  Put it off for a while as I had a couple other dongles I could use but I got a sudden urge of curiousity.  Luckily I was able to find how to get it connected, looks like all that's needed is to add an ID number to a file.

[chili555] on Ubuntu Forums had the solution, which is as follows:

1) Plug in device.  Open up a terminal and type "lsusb" then enter.  You should see a D-Link wireless adapter with ID #: 07d1:3304.  After the 'd' is a number one, not a lowercase "L".  This is what we need.  For reasons unknown to me now, this ID # wasn't included in the r8712u driver file.  So we can add that.

2) Before we do that, check that you have the r8712u driver on your computer.  Kali Linux should have it, but other Linuxes might not.  Type: "modinfo r8712u" and enter.  You should get something like this and you have the driver:

 3) So let's get this done, if you aren't root, type: "sudo -i" then enter.  If you are root you don't need sudo, and type in the quotation marks of course!  Then "modprobe r8712u" and enter.  Modprobe is a pretty low level program that edits the kernel, so you have to be careful with these commands. 

Next type: "echo -n "07d1 3304" > /sys/bus/usb/drivers/r8712u/new_id" then enter.  Then exit the terminal by typing "exit" and enter. 

Now you should get life!  The LED should begin blinking, so great to see life! And even better this dongle has a very good bit rate (72 Mb/s) so is faster than my other wifi dongles.  :)

I was able to connect to my access point after this.  If problems still persist for you there may be either potentially a hardware problem or not the right driver.  It could be a really tiny, yet hard to find problem.  Don't give up!

Link to solution thread (skip to page 4 for solution):
ubuntuforums.org/showthread.php?t=2211911

Monday, October 6, 2014

Fixing Terrible Soldering Job on a USB Hub

/***** WARNING *****/
DO NOT BUY A 7-PORT USB HUB FROM LINK DEPOT, AND COMPANY NAME IS: SHENZHEN HEXING.

What the box looks like, I wouldn't buy one


It is the worst quality I have ever seen!

Ok, so I'll keep everything I say rated "PG-13" and not say what I want to, but this was very irritating to get a product and have such low quality of manufacturing.  This is going to be more of a rant/warning that a tutorial.

I got this USB hub because I needed more USB ports to use for my Raspberry Pi, which only has 2, which are being used by a keyboard and mouse; I needed one more for file exchange.  Lots of USB hubs support Windows and Apple, but few mention Linux support.  I was wary getting one online and waiting a long time, so I saw one at my local Fry's and it looked good...on the outside...









To start off, the box itself was broken(!), I don't know how or why, but it's terrible quality control.  It was chipped and broke open when I tried to insert a USB stick into it!  Then thinking well, I might as well look at the PCB since the box is open know, what harm could be in that?  A LOT of harm!  Looks like someone deliberately tried to make a terrible quality product.

Note the holes in upper left and going across


The pins for the 5V DC power connector *WEREN'T EVEN FULLY SOLDERED*, as in one had no solder at all!  5 holes in total were on the board, atrocious soldering.  Also looked like someone burned the board a bunch of times or scratched it.  Then the LED was glued so cheaply to try and secure it in place; didn't work at all, terrible craftsmanship.

In short, it looked like a homemade hack, not an engineered product fit for commerce.

So to fix this disaster as best as I can, I want to at least fill in the missing solder holes.  The hub still powers up and works, but just looks terrible and may malfunction eventually somehow electrically due to terrible quality.

Tools needed:
--Solder iron and solder

1) Using basic soldering techniques, hold the hot iron on the corner for a few seconds, then push solder on and let the solder fill in and remove when it looks like a "shiny volcano" of metal.  That's it, repeat for the remaining holes.  In my case I had to use a lot of solder to fill the massive holes they left.

Hard to see, but bottom right is a well solder joint


Top, again hard to see...


2) Since the box won't hold together and come apart anytime I try to push in a USB stick, you have to glue the box together with a glue gun or you can wrap a few strong rubber bands around it.

Fixed PCB, still looks bad
Apologies for the bad pictures, I may re-do them at a later time, with a better camera and lighting.  Be careful when getting barebones cheap electronics from China, I've been burned other times before and some people have even *died* from fraudulent power supplies.  That is very evil and criminal and should never happen in this day and age.

Fixing Too-Small Screw-holes on 3D-Printed Box

Way back a couple years ago, I thought I'd ask my professor if I could design a 3D-printed enclosure using software we had just learned to use (Pro-Engineer, which from what I've heard isn't the best software to use for CAD-projects).  The response was yes!  So I set out measuring my passive-infrared (PIR) kit I'd gotten earlier and thought on how to make the design to hold a speaker and the PCB well.  The kit just takes 5V in and activates a speaker during detection (a "ding-dong" noise).  Took a lot of measurements, and a mistake I made was that I didn't look for proper screw sizes BEFORE designing the screw holes; I assumed I'd be able to find a screw that would work easy.







I won't be sharing the files for the box, but the box is simplistic enough (by design) to be able to copy easily if you want, it doesn't matter to me.  I was pushing for symmetry about the "Y-axis", as in you could fold it over and it would be the same.  I really liked being able to see the precision of working with CAD software and re-creating that with a 3D-printer.  It's better to see in person, but you can see some of the tiny edges that were needed for the screen on front and holding the speaker in the back.  The speaker would sit behind the PCB and be held in by that strip of plastic you see in the middle of the circle.  The PCB would be screwed in and held up by those 4 circles.

 Didn't come out perfectly though, measurements were slightly off ever though I painstakingly measured again and again.  Screw holes didn't line up and were too small.  So some advice for the readers, make sure the parts you need exist (or are easily found) BEFORE you design something needing those parts.  Sounds like common sense, but you may make the same silly mistake in the haste of trying to get things done.

Tools needed:
--Dremel tool
--Mounted pillar drill
--Wire cutters (for bits of hanging plastic)
--Proper diameter and length screws (whatever needs for your project)
--Fine-toothed hack saw

1) Started off thinking this was a job for the dremel tool, in the process learning that a dremel (at least the one I have) isn't very good for plastic.  For starters, it melts plastic and gets stuck on the drill bit and hardens to very difficult-to-remove plastic on the drill bit.  It's best to use a more powerful drill, like a mounted pillar drill; it just works better/quicker.

Be cautious and wear safety glasses when working with a pillar drill as the plastic still melts to the drill bit and then flings off at high speeds.

I also needed to make the bottom part a little bigger for the power wires at the bottom.  Found the best way to do that was using a hack saw, making a bunch of cuts close together, then coming in with the pillar drill to cut out the pieces.

2) After drilling out all the outside holes and testing the screws I had on hand (size 6, 1.5 inches long), I had some other screws that fit easily for holding the PCB in place.  I only needed to put in one here as the PCB already fit snug and if there are any problems (highly unlikely unless someone hits it hard) I can always drill out the PCB a little to make up for my faulty measurements on the screw holes.


3) After securing the PCB, make sure the screws fit snug on the outside and you can tighten and loosen them repeatedly with no problem.  The solid plastic print (you have an option to do a "solid print" or a "hollow print") for 3D-printing held up moreso than I thought it would.  The drilling likely melted some of it around the screw holes, making it slightly stronger for screws.

That's essentially it, just some manual work, it'd be better to see if I could film what I'm doing as I don't have pictures using the drill (probably a bit of a safety hazard to try filming yourself and using a drill :p) but that may come at a later time.  Also, I was having some issues for the first time with my camera and I couldn't get the best pictures.

Regardless, here's the put-together final product:





Sunday, October 5, 2014

Installing Adobe Flash to LiveUSB Kali Linux

This tutorial will be very easy and straight-forward, documenting it here mostly so I can find it quickly if I need to.  For the most part, you can get away these days without having to install Adobe Flash Player (notoriously bad for allowing all kinds of malware to take over your computer).  However, a website that is used by my school for doing homework, requires you to have Adobe Flash installed (just for certain parts, I could still get around that requirement to get credit).

So we can mitigate this risk by using a Live system, that is one that runs in RAM and has all bootloader/kernel/config files on either a CD/DVD or USB-stick. Using Adobe Flash for whatever reason you have to, then the download gets stored in RAM and is promptly wiped on shutdown.

Note that there is already a tutorial (which I did but was way more painful than this simple method), but there's a much easier way to get what you need. 

http://lewiscomputerhowto.blogspot.com/2013/10/how-to-install-adobe-flash-player-in.html

Don't laugh at how easy this is, ok? :)

Tools needed:
--Computer capable of running Kali Linux (likely most other linuxes too) with decent amount of RAM (1 GB let's say)
--An internet connection

1) Open up a terminal, type: "apt-get install flashplugin-nonfree"












You will see quite a bit of activity, lots of files downloaded.  Takes about 30 seconds to a minute to complete.

2) Once downloaded, update the plugin by typing: "update-flashplugin-nonfree --install"

That's all there is to it!  Be mindful of the spacing!  Very simple and painless and you can go do whatever you need with Adobe Flash and then shutdown to erase it (which you can verify by trying to access sites requiring Flash).

Monday, September 8, 2014

Removing Laptop WIFI Card and Camera/Microphone

So I've had some problems in the past with my Wifi/Bluetooth card and in turn the camera/microphone.  For some reason, when I didn't want any Bluetooth communications, it would turn on.  Trying to turn it off would be beyond my control.  I can end that problem by reinstalling Windows (which removes drivers) and not re-install Bluetooth drivers, and that seemed to work pretty well.  Sometimes though, I like to have an "air-gapped" computer, which means that the computer doesn't have any means of connecting to standardized communication protocols (TCP/IP, 802.11, Bluetooth LE, etc.).  For instance, if you are generating cryptographic keys on your computer for let's say PGP emails, you want to be sure that you aren't leaking those keys to a network somewhere.  There are of course still ways to capture data, but these require specialized knowledge and tools and this is a whole other topic of TEMPEST/EMSEC in computing which I won't get into today.  Removing the Wifi card is a big step.

Also I'm not much of a Skype user or a big "selfie" kind of guy and don't really have a need for a camera/microphone on my laptop.  It's just a security risk and unnecessary bloat on my computer as far as I'm concerned and there have been instances of voyeurs using malware to capture intimate moments when someone left their laptop open in their bedroom...

So if you're like me and don't need to have all this connectivity on every device you own, we want to modify that.  The laptop being used in the tutorial is a Fujitsu Lifebook A-Series.



List of Materials:
--Laptop
--Knife or paint scraper
--Screw driver
--Wire cutters

Most of the tutorial is using your hands to pry open lots of areas, very manual-intensive project.

To start, here's my working computer with the Wifi card:


1) Now flip over, take out the battery and begin taking out a lot of screws.  I won't even circle them all in pictures, there's something like 23 screws just for the exterior to be able to pry apart the plastic cover.  So just be cautious and keep track of every screw you take out.  Take out the hard drive too, it's about a 3X4" rectangle near bottom left in the picture; should slide out pretty easy.

2) Now once you're certain all screws have been removed, you can pry open a fairly large plastic cover on the bottom.  It takes a little bit of "elbow grease" to get off, and I was intially worried about breaking it.  But it will snap out.  JUST MAKE SURE YOU HAVE ALL SCREWS OUT or you may break some plastic.  Luckily for Fujitsu laptop owners, the Wifi card is right there (my finger is pointing to it).  It's held in by 1 screw and the antennas just popoff and you can pull it out.



3) However the antenna disappears to the other side and I don't want to leave that in.  Can't be yanked out.  Also at this point take out the CDROM too before you go to the other side.  There is one screw holding it in and you can use a paper clip or thin-metal object to insert in a hole by the outside to open it and just pull the unit out.



4) Now flip over to the front of the laptop.  You can pry open the speaker cover with your prying-tool of choice (needs to be thin enough) and pop that cover off.  You will see the underside of the power button and a couple speakers, as well as the hinges for the LCD screen and the screws needed to remove it.  Also you can pop out the keyboard BUT BE VERY CAREFUL as I popped out the thin cable for the keyboard and nearly needed to go to a repair shop.  You really don't need to take out the keyboard for this though, but you might as well take a peek now anyway if you want.  The Wifi antenna continues on up the right hinge up into the LCD screen, so we need to remove that.



5) Now there's 2 screws holding the screen to the computer, take them off and lift up the LCD screen.  You can pull the antenna thru so the screen can be completely removed.  Again, be cautious and patient so you don't end up need a new LCD screen.




6) There's 4 screws on the outside corners of the screen, which are covered up with black rubber bumpers.  You have to pop those off and unscrew the screws.  Prying it open carefully, you can see the antenna going up the right side.  Keep pulling it out and moving up to the embedded camera/microphone at the top of the screen.  There you'll see the antennas soldered to be held in place and the 2 antennas aren't the same size.  Snip them off with wire cutters and you got all the antennas.  Down the backside of the LCD is where the camera/microphone get power.  I simply snipped that with wire cutters and pulled out the camera/microphone.



7) Here's the removed components, antennas, Wifi card, and camera/microphone.  It's an Intel Centrino Wireless-N-1030 module with Bluetooth.  I don't know what brand the camera/microphone is.

[PDF WARNING]

http://www.intel.com/content/dam/www/public/us/en/documents/product-briefs/centrino-wireless-n-1030-brief.pdf



8) And now you have to reverse everything you did and put everything back together.  You should do it as soon as possible and not put it off because you may forget some things.  Here's my laptop working again, and hmm..It was having trouble finding the Intel Wireless card, huh..weird. :P  Connecting to wifi is still possible with the multitude of wifi-USB modules that are available, I have an old D-Link one and I just needed to download a driver from a website (on another computer of course!).  And now I can connect to wifi when I want and have a reasonable assurance that when I don't want to, it's close to not possible.  Speakers stayed in but I may remove them too in the future.  Be safe and protect yourself.