WIP Feature: Add UID modifier
This commit is contained in:
parent
3cb47059aa
commit
56d8bde7cb
7 changed files with 38 additions and 38 deletions
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-g -Wall
|
CFLAGS=-g -Wall -Iinclude
|
||||||
SRC=src
|
SRC=src
|
||||||
OBJ=obj
|
OBJ=obj
|
||||||
SRCS=$(wildcard $(SRC)/*.c)
|
SRCS=$(wildcard $(SRC)/*.c)
|
||||||
|
|
Binary file not shown.
4
include/modifyUID.h
Normal file
4
include/modifyUID.h
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "colors.h"
|
||||||
|
|
||||||
|
void modifyUID(FILE *file);
|
19
makefile
19
makefile
|
@ -1,19 +0,0 @@
|
||||||
CC = gcc
|
|
||||||
CFLAGS = -Wall -I$(INCLUDE)
|
|
||||||
INCLUDE = include
|
|
||||||
SRC_DIR = src
|
|
||||||
OBJ_DIR = obj
|
|
||||||
SRC = $(wildcard $(SRC_DIR)/*.c)
|
|
||||||
OBJ = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC))
|
|
||||||
BIN = ./main
|
|
||||||
|
|
||||||
all: $(BIN)
|
|
||||||
|
|
||||||
$(BIN): $(OBJ)
|
|
||||||
$(CC) -o $@ $^
|
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c MKOBJ
|
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OBJ_DIR)/*.o $(BIN)
|
|
|
@ -5,7 +5,7 @@
|
||||||
void getSize(FILE *file, int argc, char *argv[]) {
|
void getSize(FILE *file, int argc, char *argv[]) {
|
||||||
fseek(file, 0L, SEEK_END);
|
fseek(file, 0L, SEEK_END);
|
||||||
long bytes = ftell(file);
|
long bytes = ftell(file);
|
||||||
fseek(file, 0L, SEEK_SET);
|
rewind(file); // <== Same as `fseek(file, 0L, SEEK_SET)`;
|
||||||
if (bytes == 1024) {
|
if (bytes == 1024) {
|
||||||
printf("Bytes of %s: %ld\n", argv[argc - 1], bytes);
|
printf("Bytes of %s: %ld\n", argv[argc - 1], bytes);
|
||||||
puts("This looks like a Mifare Classic 1K dump file");
|
puts("This looks like a Mifare Classic 1K dump file");
|
||||||
|
|
41
src/main.c
41
src/main.c
|
@ -6,28 +6,35 @@
|
||||||
|
|
||||||
#include "getSize.h"
|
#include "getSize.h"
|
||||||
#include "readFile.h"
|
#include "readFile.h"
|
||||||
|
#include "modifyUID.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (argv[argc] == 1) {
|
if (argc <= 1) {
|
||||||
|
puts("Please, specify a file next to the executable\n");
|
||||||
|
printf("Example:\n\t%s [file]\n", argv[0]);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *file;
|
||||||
|
char *binfile = malloc(64 * sizeof(char));
|
||||||
|
if (binfile == NULL) {
|
||||||
|
puts("Failed to allocate memory");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
FILE *file;
|
file = fopen(argv[argc - 1], "r+b");
|
||||||
char *binfile = malloc(64 * sizeof(char));
|
if (file == NULL) {
|
||||||
if (binfile == NULL) {
|
perror("Error while opening the file");
|
||||||
puts("Failed to allocate memory");
|
exit(EXIT_FAILURE);
|
||||||
exit(EXIT_FAILURE);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
file = fopen(argv[argc - 1], "rb");
|
// readFile(file);
|
||||||
if (file == NULL) {
|
// getSize(file, argc, argv);
|
||||||
perror("Error while opening the file");
|
modifyUID(file);
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
readFile(file);
|
fclose(file);
|
||||||
|
free(binfile);
|
||||||
fclose(file);
|
exit(EXIT_SUCCESS);
|
||||||
free(binfile);
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
8
src/modifyUID.c
Normal file
8
src/modifyUID.c
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "colors.h"
|
||||||
|
|
||||||
|
void modifyUID(FILE *file) {
|
||||||
|
fseek(file, 0, SEEK_SET);
|
||||||
|
unsigned char newByte = 0x67;
|
||||||
|
fwrite(&newByte, sizeof(newByte), 1, file);
|
||||||
|
}
|
Loading…
Reference in a new issue