コード例 #1
0
ファイル: snooper.c プロジェクト: JohnDMcMaster/proxmark3
int main()
{
  usb_init();
  SetLogFilename("snooper.log");

  g_return_on_error = 1;

  while(1) {
    while (!OpenProxmark(0)) { sleep(1); }
    while (1) {
      UsbCommand cmdbuf;
      CommandReceived("hf 14a snoop");
      HANDLE_ERROR;
      ReceiveCommand(&cmdbuf);
      HANDLE_ERROR;
      for (int i = 0; i < 5; ++i) {
        ReceiveCommandPoll(&cmdbuf);
      }
      HANDLE_ERROR;
      CommandReceived("hf 14a list");
      HANDLE_ERROR;
    }
  }

  CloseProxmark();
  return 0;
}
コード例 #2
0
ファイル: flash.c プロジェクト: thefkboss/proxmark3
// Enter the bootloader to be able to start flashing
static int enter_bootloader(char *serial_port_name)
{
	uint32_t state;

	if (get_proxmark_state(&state) < 0)
		return -1;

	if (state & DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM) {
		/* Already in flash state, we're done. */
		return 0;
	}

	if (state & DEVICE_INFO_FLAG_CURRENT_MODE_OS) {
		fprintf(stderr,"Entering bootloader...\n");
		UsbCommand c;
		memset(&c, 0, sizeof (c));

		if ((state & DEVICE_INFO_FLAG_BOOTROM_PRESENT)
			&& (state & DEVICE_INFO_FLAG_OSIMAGE_PRESENT))
		{
			// New style handover: Send CMD_START_FLASH, which will reset the board
			// and enter the bootrom on the next boot.
			c.cmd = CMD_START_FLASH;
			SendCommand(&c);
			fprintf(stderr,"(Press and release the button only to abort)\n");
		} else {
			// Old style handover: Ask the user to press the button, then reset the board
			c.cmd = CMD_HARDWARE_RESET;
			SendCommand(&c);
			fprintf(stderr,"Press and hold down button NOW if your bootloader requires it.\n");
		}
    msleep(100);
		CloseProxmark();

		fprintf(stderr,"Waiting for Proxmark to reappear on %s",serial_port_name);
    do {
			sleep(1);
			fprintf(stderr, ".");
		} while (!OpenProxmark(0));
		fprintf(stderr," Found.\n");

		return 0;
	}

	fprintf(stderr, "Error: Unknown Proxmark mode\n");
	return -1;
}
コード例 #3
0
ファイル: cli.c プロジェクト: shangdawei/proxmark3-lcd
int main(int argc, char **argv)
{
    if (argc != 3 && argc != 4)
    {
        printf("\n\tusage: cli <command 1> <command 2> [logfile (default cli.log)]\n");
        printf("\n");
        printf("\texample: cli hi14asnoop hi14alist h14a.log\n");
        printf("\n");
        return -1;
    }

    usb_init();
    if (argc == 4)
        SetLogFilename(argv[3]);
    else
        SetLogFilename("cli.log");

    return_on_error = 1;

    while (1) {
        while (!OpenProxmark(0)) {
            sleep(1);
        }
        while (1) {
            UsbCommand cmdbuf;
            CommandReceived(argv[1]);
            HANDLE_ERROR;
            ReceiveCommand(&cmdbuf);
            HANDLE_ERROR;
            for (int i = 0; i < 5; ++i) {
                ReceiveCommandPoll(&cmdbuf);
            }
            HANDLE_ERROR;
            CommandReceived(argv[2]);
            HANDLE_ERROR;
        }
    }

    CloseProxmark();
    return 0;
}
コード例 #4
0
ファイル: proxmark3.c プロジェクト: LucaBongiorni/proxmark3
int main(int argc, char **argv)
{
  // Make sure to initialize
  struct main_loop_arg marg = {
    .usb_present = 0,
    .script_cmds_file = NULL
  };
  pthread_t main_loop_t;
  usb_init();

  // If the user passed the filename of the 'script' to execute, get it
  if (argc > 1 && argv[1])
  {
    marg.script_cmds_file = argv[1];
  }

  if (!OpenProxmark(1)) {
    fprintf(stderr,"PROXMARK3: NOT FOUND!\n");
    marg.usb_present = 0;
    offline = 1;
  } else {
    marg.usb_present = 1;
    offline = 0;
  }

  pthread_create(&main_loop_t, NULL, &main_loop, &marg);
  InitGraphics(argc, argv);

  MainGraphics();

  pthread_join(main_loop_t, NULL);

  if (marg.usb_present == 1) {
    CloseProxmark();
  }
  return 0;
}
コード例 #5
0
ファイル: flasher.c プロジェクト: glocklueng/proxmark3-lcd
int main(int argc, char **argv)
{
	int can_write_bl = 0;
	int num_files = 0;
	int res;
	flash_file_t files[MAX_FILES];

	memset(files, 0, sizeof(files));

	if (argc < 2) {
		usage(argv[0]);
		return -1;
	}

	for (int i = 1; i < argc; i++) {
		if (argv[i][0] == '-') {
			if (!strcmp(argv[i], "-b")) {
				can_write_bl = 1;
			} else {
				usage(argv[0]);
				return -1;
			}
		} else {
			res = flash_load(&files[num_files], argv[i], can_write_bl);
			if (res < 0) {
				fprintf(stderr, "Error while loading %s\n", argv[i]);
				return -1;
			}
			fprintf(stderr, "\n");
			num_files++;
		}
	}

	usb_init();

	fprintf(stderr, "Waiting for Proxmark to appear on USB...");
	while (!OpenProxmark(0)) {
		sleep(1);
		fprintf(stderr, ".");
	}
	fprintf(stderr, " Found.\n");

	res = flash_start_flashing(can_write_bl);
	if (res < 0)
		return -1;

	fprintf(stderr, "\nFlashing...\n");

	for (int i = 0; i < num_files; i++) {
		res = flash_write(&files[i]);
		if (res < 0)
			return -1;
		flash_free(&files[i]);
		fprintf(stderr, "\n");
	}

	fprintf(stderr, "Resetting hardware...\n");

	res = flash_stop_flashing();
	if (res < 0)
		return -1;

	CloseProxmark();

	fprintf(stderr, "All done.\n\n");
	fprintf(stderr, "Have a nice day!\n");

	return 0;
}