Exemple #1
0
static void pwn(const char * fname)
{
	REQUIRE(fname != NULL);

	struct wif * wi;
	char crap[2048];
	int rc;

	if (strlen(fname) + 7 >= sizeof(crap))
	{
		printf("Filename too long, aborting\n");
		return;
	}

	memset(crap, 0, sizeof(crap));
	snprintf(crap, sizeof(crap), "file://%s", fname);

	wi = wi_open(crap);
	if (!wi)
	{
		printf("Bad file - skipping %s\n", fname);
		return;
	}

	while ((rc = wi_read(wi, (unsigned char *) crap, sizeof(crap), NULL)) > 0)
		process_packet(crap, rc);

	wi_close(wi);
}
static void
wavelan_free(Control *ctrl)
{
	t_wavelan *wavelan;
  int n;

	g_return_if_fail(ctrl != NULL);
	g_return_if_fail(ctrl->data != NULL);

	wavelan = (t_wavelan *)ctrl->data;

  /* free tooltips */
  g_object_unref(G_OBJECT(wavelan->tooltips));

  /* free pixbufs */
  for (n = 0; n < 7; ++n)
    if (wavelan->pb[n] != NULL)
      g_object_unref(G_OBJECT(wavelan->pb[n]));

  /* unregister the timer */
  if (wavelan->timer_id != 0)
    gtk_timeout_remove(wavelan->timer_id);

  /* free the device info */
  if (wavelan->device != NULL)
    wi_close(wavelan->device);

  if (wavelan->interface != NULL)
    g_free(wavelan->interface);
	g_free(wavelan);
}
Exemple #3
0
struct wif *file_open(char *iface)
{
	struct wif *wi;
	struct priv_file *pf;
	int fd;
        struct pcap_file_header pfh;
	int rc;

	if (strncmp(iface, "file://", 7) != 0)
		return NULL;

	/* setup wi struct */
	wi = wi_alloc(sizeof(*pf));
	if (!wi)
		return NULL;

	wi->wi_read		= file_read;
	wi->wi_write		= file_write;
	wi->wi_set_channel	= file_set_channel;
	wi->wi_get_channel	= file_get_channel;
        wi->wi_set_rate    	= file_set_rate;
	wi->wi_get_rate    	= file_get_rate;
	wi->wi_close		= file_close;
	wi->wi_fd		= file_fd;
	wi->wi_get_mac		= file_get_mac;
	wi->wi_get_monitor	= file_get_monitor;

        pf = wi_priv(wi);

	fd = open(iface + 7, O_RDONLY);
	if (fd == -1)
		err(1, "open()");

	pf->pf_fd = fd;

	if ((rc = read(fd, &pfh, sizeof(pfh))) != sizeof(pfh))
		goto __err;

	if (pfh.magic != TCPDUMP_MAGIC)
		goto __err;

	if (pfh.version_major != PCAP_VERSION_MAJOR
	    || pfh.version_minor != PCAP_VERSION_MINOR)
		goto __err;

	pf->pf_dtl = pfh.linktype;

	return wi;

__err:
	wi_close(wi);
	return (struct wif*) -1;
}
static void pwn(char *fname)
{
	struct wif *wi;
	char crap[2048];
	int rc;

	snprintf(crap, sizeof(crap), "file://%s", fname);

	wi = wi_open(crap);
	if (!wi) {
		printf("Bad file - skipping %s\n", fname);
		return;
	}

	while ((rc = wi_read(wi, (unsigned char*) crap, sizeof(crap), NULL)) > 0)
		process_packet(crap, rc);

	wi_close(wi);
}
static void
wavelan_configure(t_wavelan *wavelan)
{
  if (wavelan->timer_id != 0) {
    gtk_timeout_remove(wavelan->timer_id);
    wavelan->timer_id = 0;
  }

  if (wavelan->device != NULL) {
    wi_close(wavelan->device);
    wavelan->device = NULL;
  }

  if (wavelan->interface != NULL) {
    /* open the WaveLAN device */
    if ((wavelan->device = wi_open(wavelan->interface)) != NULL) {
      /* register the update timer */
      wavelan->timer_id = gtk_timeout_add(250, wavelan_timer, wavelan);
    }
  }
}
Exemple #6
0
static void cleanup(int x)
{
	struct wstate *ws = get_ws();

	printf("\n");
	time_print("Dying...\n");

	if (x) {} /* XXX unused */

	if (ws->ws_fd)
		close(ws->ws_fd);

	kill_crack(ws);

	if (ws->ws_wi)
		wi_close(ws->ws_wi);

	if(ws->ws_ssid)
		free(ws->ws_ssid);

	exit(0);
}