#
#
# MDcrack Makefile
#
# Gregory Duchemin, 11 Feb 2001
# c3rb3r@hotmail.com
#
#
#



CC = gcc

# Please set RESUME_FILE and choose a secure place for the resume file 
# before using mdcrack as root.
# default is NOT secure and own an obvious race condition.
# Nevertheless Mdcrack offer a protection against symlink attack style and will not create a resume file across a pre existing symlink.

# BENCH_HASH corresponds to the default benchmark hash 
# In fact i did not try it no more longer than 10 secs, however if 
# it would collide too quickly for your tests, change it.
 
# ALFA is the default charset string used to design passwords. 
# We can still use a customized one with -s option on the command line.

MDCRACK_OPTS=  -DRESUME_FILE="\"/tmp/.mdcrack-resume\"" -DBENCH_HASH="\"ffffffffffffffffffffffffffffffff\"" -DALFA="\"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\""

# INF64 will determine if the designed passwords can be larger than a single 
# MD5 block, this value include naturaly eventual randomizer string.
# Performance are affected if u decide to try larger passwords that don't
# fit into 64bits block.


MDFLAGS= -DINF64=1


# Just type, "make big", on BIG ENDIAN architectures if u don't want to catch ghosts instead of collisions.

MDARCH= 


# BLOCKSIZE in MB is used for file bufferization. The input file is read block by block in memory, set the value as high as possible accordingly to your system size (memory, system load, disk speed etc...).
# UNIX users: Do not forget to check your actual disk configuration with hdparm and if not already done, switch ON 32 bits mode and DMA when possible.
# #hdparm -c 1 -d 1 /dev/hd*

BLOCK=-DBLOCKSIZE=50

#full optimization
CFLAGS =  -O3 -fforce-addr -funroll-loops -fomit-frame-pointer -ffast-math 



# Ncurses, uncomment these 2 lines if you wish colors in your life.
NCURSES=
NCURSES=-DNCURSES 

#LDFLAGS=
LDFLAGS=-lncurses



default:
	@echo 
	@echo "####  NOTE  #########################################"
	@echo "MDcrack is compiling for little endian processors."
	@echo "Try: \"make big\" if u need a big endian binary."
	@echo
	@make bin/mdcrack 



bin/mdcrack: src/md5c.o src/title.o src/mdcrack.o src/stats.o src/mesgs.o src/hash.o src/charset.o
	$(CC) $(LDFLAGS) -o bin/mdcrack src/title.o src/mesgs.o src/md5c.o src/mdcrack.o src/stats.o  src/hash.o src/charset.o
	@echo
	@echo "ok."
	@echo
	@echo
	@echo "to install -- \"make install\""
	@echo "to test -- \"make test/bigtest\""
	@echo


big:
	@echo
	@echo "####  NOTE  #########################################"
	@echo "MDcrack is compiling for big endian processors."
	@echo "Try: \"make\" if u need a little endian binary."
	@echo
	@make bin/mdcrack MDARCH="-DISBIG_ENDIAN=1"



src/mdcrack.o: src/generic.h src/mdcrack.c 
	$(CC)  -c $(CFLAGS) $(NCURSES) $(CPU) $(MDCRACK_OPTS) $(MDARCH) $(BLOCK) src/mdcrack.c -o src/mdcrack.o

src/title.o: src/generic.h src/title.c 
	$(CC)  -c $(CFLAGS) $(NCURSES) $(CPU) $(MDCRACK_OPTS) $(MDARCH) $(BLOCK) src/title.c -o src/title.o

src/md5c.o: src/generic.h src/md5c.c
	$(CC) -c $(MDFLAGS) $(NCURSES) $(CPU) $(CFLAGS) $(MDARCH) src/md5c.c -o src/md5c.o

src/stats.o: src/generic.h src/stats.c
	$(CC) -c $(MDFLAGS) $(NCURSES) $(CPU) $(CFLAGS) $(MDARCH) src/stats.c -o src/stats.o

src/mesgs.o: src/generic.h src/version.h src/mesgs.c
	$(CC) -c $(MDFLAGS) $(NCURSES) $(CPU) $(CFLAGS) $(MDARCH) src/mesgs.c -o src/mesgs.o

src/hash.o: src/hash.c
	$(CC) -c $(MDFLAGS) $(NCURSES) $(CPU) $(CFLAGS) $(MDARCH) src/hash.c -o src/hash.o

src/charset.o: src/charset.c
	$(CC) -c $(MDFLAGS) $(NCURSES) $(CPU) $(CFLAGS) $(MDARCH) src/charset.c -o src/charset.o



test: 
	@make default
	@echo
	@echo  "Test: Cracking \"toto\" string with [a-z0-9] charset."
	@echo
	bin/mdcrack -s abcdefghijklmnopqrstuvwxyz0123456789 f71dbe52628a3f83a77ab494817525c6
	@echo
	@echo  "ok."
	@echo


bigtest:
	@make default
	@echo
	@echo  "Big test: Cracking \"toto\" string with [a-zA-Z0-9] charset."
	@echo
	bin/mdcrack f71dbe52628a3f83a77ab494817525c6 
	@echo
	@echo  "ok."
	@echo



clean:
	@echo
	@echo  "Cleaning binaries..."
	rm -f src/*.o src/*~  
	rm -f bin/*~ bin/mdcrack 
	@echo
	@echo  "ok."
	@echo

install: 
	@make default
	@echo
	@echo  "Installing mdcrack in /usr/sbin/mdcrack"
	cp bin/mdcrack /usr/sbin/mdcrack
	@echo
	@echo "ok."
	@echo

