Difference between revisions of "Lauscher.cpp"

From ThorstensHome
Jump to: navigation, search
(See also)
 
Line 42: Line 42:
 
* [[Das Elektronik Buch]]
 
* [[Das Elektronik Buch]]
 
* [[ftdi]]
 
* [[ftdi]]
 +
* http://electroments.blogspot.de/2013/06/lauschangriff-auf-das-usb-kabel.html

Latest revision as of 12:48, 27 July 2013

Mit diesem Beispiel kann ein 5V Bus belauscht werden:

/*
 * lauscher.c (c) 2013 by Thorsten Staerk, www.staerk.de/thorsten
 * 
 * This program allows you to listen to a USB wire. Just connect it to DTS 
 * of an ftdi chip
 * 
 * Compile with
 * gcc -lftdi lauscher.c
 */

#include <stdio.h>
#include <ftdi.h>

int main() 
{
    int result=0;
    struct ftdi_context context1;
    if (ftdi_init(&context1) >= 0) 
    {
        if (ftdi_usb_open(&context1, 0x0403, 0x6001) >= 0) // ft232r
        {
            while (1)
            {
	        unsigned char buf;
	        printf("%d\n",ftdi_read_pins (&context1, &buf));
	        printf("%d\n",buf);
            }

            if (ftdi_usb_close(&context1) < 0) result = EXIT_FAILURE;
        }
        else result = EXIT_FAILURE;
    }
    else result = EXIT_FAILURE;
    if (result) fprintf(stderr, "Fehler: %s\n", ftdi_get_error_string(&context1));
    return result;
}

See also