예제 #1
0
파일: PyLorcon2.c 프로젝트: 0x0d/lorcon
static PyObject*
PyLorcon2_find_driver(PyObject *self, PyObject *args)
{
    char *name;
    PyObject* retval;
    lorcon_driver_t *driver;

    if (!PyArg_ParseTuple(args, "s", &name))
        return NULL;

    driver = lorcon_find_driver(name);
    if (!driver) {
        PyErr_SetString(Lorcon2Exception, "Unable to get driver-list");
        return NULL;
    }

    retval = PyTuple_New(2);
    if (!retval) {
        lorcon_free_driver_list(driver);
        return PyErr_NoMemory();
    }
    
    PyTuple_SetItem(retval, 0, PyString_FromString(driver->name));
    PyTuple_SetItem(retval, 1, PyString_FromString(driver->details));

    lorcon_free_driver_list(driver);

    return retval;
}
예제 #2
0
파일: PyLorcon2.c 프로젝트: 0x0d/lorcon
static PyObject*
PyLorcon2_list_drivers(PyObject *self, PyObject *args)
{
    PyObject *retval, *entry;
    lorcon_driver_t *driver_list, *driver;
    
    driver = driver_list = lorcon_list_drivers();
    if (!driver) {
        PyErr_SetString(Lorcon2Exception, "Unable to get driver-list");
        return NULL;
    }

    retval = PyList_New(0);
    if (!retval) {
        lorcon_free_driver_list(driver_list);
        return PyErr_NoMemory();
    }

    while(driver) {
        entry = PyTuple_New(2);

        PyTuple_SetItem(entry, 0, PyString_FromString(driver->name));
        PyTuple_SetItem(entry, 1, PyString_FromString(driver->details));

        PyList_Append(retval, entry);
        Py_DECREF(entry);

        driver = driver->next;
    }

    lorcon_free_driver_list(driver_list);

    return retval;
}
예제 #3
0
파일: PyLorcon2.c 프로젝트: 0x0d/lorcon
static int
PyLorcon2_Context_init(PyLorcon2_Context *self, PyObject *args, PyObject *kwds)
{
    lorcon_driver_t *driver;
    static char *kwlist[] = {"iface", NULL};
    char *iface;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &iface))
        return -1;

    driver = lorcon_auto_driver(iface);
    if (!driver) {
        PyErr_SetString(Lorcon2Exception, "Unable to get driver");
        return -1;
    }

    self->context = lorcon_create(iface, driver);

    lorcon_free_driver_list(driver);

    if (!self->context) {
        PyErr_SetString(Lorcon2Exception, "Unable to create lorcon context");
        return -1;
    }
    
    self->monitored = 0;
    lorcon_set_timeout(self->context, 100);

    return 0;
}
예제 #4
0
static VALUE Lorcon_list_drivers(VALUE self) {
	VALUE list;
	VALUE hash;

	lorcon_driver_t *drvlist, *dri;

	list = rb_hash_new();

	dri = drvlist = lorcon_list_drivers();

	if (dri == NULL)
		return Qnil;

	while (dri) {
		hash = rb_hash_new();
		rb_hash_aset(hash, rb_str_new2("name"), rb_str_new2(dri->name));
		rb_hash_aset(hash, rb_str_new2("description"), rb_str_new2(dri->details));
		rb_hash_aset(list, rb_str_new2(dri->name),hash);
		dri = dri->next;
	}

	lorcon_free_driver_list(drvlist);

	return(list);
}
예제 #5
0
	int DeviceProxy_dot11::connect(int timeout) {
		if ( interface == ""  ) { 
			fprintf(stderr, "ERROR: 802.11 interface not set\n");
			return 1;
		}
		fprintf(stderr, "802.11: Using interface %s\n", interface.c_str());
		if ( (driver = lorcon_auto_driver(interface.c_str())) == NULL) {
			fprintf(stderr, "ERROR: 802.11: Could not determine the driver for %s\n",interface.c_str());
			return 1;
		} else {
			fprintf(stderr, "802.11:  Driver: %s\n",driver->name);
		}
	
		// Create LORCON context
		if ((context = lorcon_create(interface.c_str(), driver)) == nullptr) {
				fprintf(stderr, "Error: 802.11:  Failed to create context");
				return 1; 
		}
		int rv = lorcon_open_monitor(context);
		if (rv < 0) {
			fprintf(stderr, "Error: 802.11: Could not create Monitor Mode interface!\n");
			return 1;
		} else {
			fprintf(stderr, "802.11: Monitor Mode VAP: %s, (%d)\n",
					lorcon_get_vap(context), rv);
			monitor = true;
		}
		lorcon_free_driver_list(driver);
		
		p_is_connected = true;
		return 0;
	}
예제 #6
0
static VALUE Lorcon_create(int argc, VALUE *argv, VALUE self) {
	struct rldev *rld;
	char *intf = NULL, *driver = NULL;
	VALUE rbdriver, rbintf, obj;
	lorcon_driver_t *dri;

	if (argc == 2) {
		rb_scan_args(argc, argv, "2", &rbintf, &rbdriver);
		intf = StringValuePtr(rbintf);
		driver = StringValuePtr(rbdriver);
	} else {
		rb_scan_args(argc, argv, "1", &rbintf);
		intf = StringValuePtr(rbintf);
	}
	
	if (driver == NULL) {
		if ((dri = lorcon_auto_driver(intf)) == NULL) {
			rb_raise(rb_eRuntimeError,
					 "LORCON could not detect a driver and none specified");
			return (Qnil);
		}
	} else {
		if ((dri = lorcon_find_driver(driver)) == NULL) {
			rb_raise(rb_eArgError,
					 "LORCON could not recognize the specified driver");
			return (Qnil);
		}
	}

	obj = Data_Make_Struct(cDevice, struct rldev, 0, Lorcon_free, rld);

	rld->context = lorcon_create(intf, dri);
	
	// Obsolete: XXX
	// lorcon_set_timeout(rld->context, 100);
		
	if (rld->context == NULL) {
		rb_raise(rb_eRuntimeError,
				 "LORCON could not create context");
		return (Qnil);
	}

	lorcon_free_driver_list(dri);

	rb_obj_call_init(obj, 0, 0);	
	return(obj);
}
예제 #7
0
static VALUE Lorcon_auto_driver(VALUE self, VALUE interface) {
	VALUE hash;
	lorcon_driver_t *dri;
	char *intf = RSTRING_PTR(interface);

	dri = lorcon_auto_driver(intf);

	if (dri == NULL)
		return Qnil;

	hash = rb_hash_new();
	rb_hash_aset(hash, rb_str_new2("name"), rb_str_new2(dri->name));
	rb_hash_aset(hash, rb_str_new2("description"), rb_str_new2(dri->details));

	lorcon_free_driver_list(dri);

	return hash;
}
예제 #8
0
static VALUE Lorcon_find_driver(VALUE self, VALUE driver) {
	VALUE hash;
	lorcon_driver_t *dri;
	char *drivert = RSTRING_PTR(driver);

	dri = lorcon_find_driver(drivert);

	if (dri == NULL)
		return Qnil;

	hash = rb_hash_new();

	rb_hash_aset(hash, rb_str_new2("name"), rb_str_new2(dri->name));
	rb_hash_aset(hash, rb_str_new2("description"), rb_str_new2(dri->details));

	lorcon_free_driver_list(dri);

	return(hash);
}
예제 #9
0
파일: tx.c 프로젝트: 0x0d/lorcon
void usage()
{
	lorcon_driver_t *drvlist, *dri;

	printf("tx (c) 2005 Joshua Wright and dragorn\n"
	       "Usage : tx [options]\n"
	       "  -i <interface>       specify the interface name\n"
	       "  -n <number>          number of packets to send\n"
	       "  -c <channel>         channel to transmit packets on.\n"
	       "  -s <sleep>           sleep time in usec between packets.\n"
	       "  -d <drivername>      string indicating driver used on interface\n");

	dri = drvlist = lorcon_list_drivers();

	printf("Supported LORCON drivers:\n");
	while (dri) {
		printf("%-10.10s %s\n", dri->name, dri->details);
		dri = dri->next;
	}

	lorcon_free_driver_list(drvlist);
}
예제 #10
0
int main(int argc, char *argv[]) {

	char *interface = NULL, *ssid = NULL;
	int c, channel;
	unsigned int count=0;

	lorcon_driver_t *drvlist, *driver; // Needed to set up interface/context
	lorcon_t *context; // LORCON context

	// Beacon Interval
        int interval = 100;

	// Raw packet bytes (from capture_example.c included within LORCON)
	unsigned char packet[115] = {
        0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // dur ffff
        0xff, 0xff, 0x00, 0x0f, 0x66, 0xe3, 0xe4, 0x03,
        0x00, 0x0f, 0x66, 0xe3, 0xe4, 0x03, 0x00, 0x00, // 0x0000 - seq no.
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // BSS timestamp
        0x64, 0x00, 0x11, 0x00, 0x00, 0x0f, 0x73, 0x6f,
        0x6d, 0x65, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x63,
        0x6c, 0x65, 0x76, 0x65, 0x72, 0x01, 0x08, 0x82,
        0x84, 0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, 0x03,
        0x01, 0x01, 0x05, 0x04, 0x00, 0x01, 0x00, 0x00,
        0x2a, 0x01, 0x05, 0x2f, 0x01, 0x05, 0x32, 0x04,
        0x0c, 0x12, 0x18, 0x60, 0xdd, 0x05, 0x00, 0x10,
        0x18, 0x01, 0x01, 0xdd, 0x16, 0x00, 0x50, 0xf2,
        0x01, 0x01, 0x00, 0x00, 0x50, 0xf2, 0x02, 0x01,
        0x00, 0x00, 0x50, 0xf2, 0x02, 0x01, 0x00, 0x00,
        0x50, 0xf2, 0x02};



	printf ("%s - Simple 802.11 beacon flooder\n", argv[0]);
	printf ("-----------------------------------------------------\n\n");

	/* 
		This handles all of the command line arguments
	*/
	
	while ((c = getopt(argc, argv, "i:s:hc:")) != EOF) {
		switch (c) {
			case 'i': 
				interface = strdup(optarg);
				break;
			case 'c':
				channel = atoi(optarg);
				break;
			case 'h':
				usage(argv);
				break;
			default:
				usage(argv);
				break;
			}
	}

	if ( interface == NULL  ) { 
		printf ("ERROR: Interface not set (see -h for more info)\n");
		return -1;
	}

	printf("[+] Using interface %s\n",interface);
	
	/*	
	 	The following is all of the standard interface, driver, and context setup
	*/

	// Automatically determine the driver of the interface
	
	if ( (driver = lorcon_auto_driver(interface)) == NULL) {
		printf("[!] Could not determine the driver for %s\n",interface);
		return -1;
	} else {
		printf("[+]\t Driver: %s\n",driver->name);
	}

	// Create LORCON context
        if ((context = lorcon_create(interface, driver)) == NULL) {
                printf("[!]\t Failed to create context");
               	return -1; 
        }

	// Create Monitor Mode Interface
	if (lorcon_open_injmon(context) < 0) {
		printf("[!]\t Could not create Monitor Mode interface!\n");
		return -1;
	} else {
		printf("[+]\t Monitor Mode VAP: %s\n",lorcon_get_vap(context));
		lorcon_free_driver_list(driver);
	}

	// Set the channel we'll be injecting on
	lorcon_set_channel(context, channel);
	printf("[+]\t Using channel: %d\n\n",channel);

	/* 
		The following is the packet creation and sending code
	*/

	// Keep sending frames until interrupted
	while(1) {

		// Send and exit if error
		if ( lorcon_send_bytes(context, sizeof(packet), packet) < 0 ) 
			return -1;

               // Wait interval before next beacon
                usleep(interval * 1000);

		// Print nice and pretty
		printf("\033[K\r");
		printf("[+] Sent %d frames, Hit CTRL + C to stop...", count);
		fflush(stdout);
		count++;

	}

	/* 
	 	The following is all of the standard cleanup stuff
	*/

	// Close the interface
	lorcon_close(context);

	// Free the LORCON Context
	lorcon_free(context);	
	
	return 0;
}