WIP Feature: Add UID modifier

This commit is contained in:
Fijxu 2023-12-26 03:09:28 -03:00
parent 3cb47059aa
commit 56d8bde7cb
7 changed files with 38 additions and 38 deletions

View File

@ -1,5 +1,5 @@
CC=gcc
CFLAGS=-g -Wall
CFLAGS=-g -Wall -Iinclude
SRC=src
OBJ=obj
SRCS=$(wildcard $(SRC)/*.c)

Binary file not shown.

4
include/modifyUID.h Normal file
View File

@ -0,0 +1,4 @@
#include <stdio.h>
#include "colors.h"
void modifyUID(FILE *file);

View File

@ -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)

View File

@ -5,7 +5,7 @@
void getSize(FILE *file, int argc, char *argv[]) {
fseek(file, 0L, SEEK_END);
long bytes = ftell(file);
fseek(file, 0L, SEEK_SET);
rewind(file); // <== Same as `fseek(file, 0L, SEEK_SET)`;
if (bytes == 1024) {
printf("Bytes of %s: %ld\n", argv[argc - 1], bytes);
puts("This looks like a Mifare Classic 1K dump file");

View File

@ -6,28 +6,35 @@
#include "getSize.h"
#include "readFile.h"
#include "modifyUID.h"
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;
char *binfile = malloc(64 * sizeof(char));
if (binfile == NULL) {
puts("Failed to allocate memory");
exit(EXIT_FAILURE);
}
file = fopen(argv[argc - 1], "r+b");
if (file == NULL) {
perror("Error while opening the file");
exit(EXIT_FAILURE);
}
file = fopen(argv[argc - 1], "rb");
if (file == NULL) {
perror("Error while opening the file");
exit(EXIT_FAILURE);
}
// readFile(file);
// getSize(file, argc, argv);
modifyUID(file);
readFile(file);
fclose(file);
free(binfile);
exit(EXIT_SUCCESS);
fclose(file);
free(binfile);
exit(EXIT_SUCCESS);
}

8
src/modifyUID.c Normal file
View 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);
}