#!/usr/bin/expect -f

# set vars
set pm3 [lindex $argv 0]
set uid [lindex $argv 1]
set i 0

# run pm3 client
spawn sudo $pm3

# clear emulator memory
expect "proxmark3> "
send "hf mf eclr\r"
expect "proxmark3> "

# open file
set fhandle [open clone r]

while {[gets $fhandle inline] >= 0} {
    # set emulator blocks
    send "hf mf eset $i $inline\r"
    expect "proxmark3> "
    incr i 1
}
# close file
close $fhandle

# enter sim command
send "hf mf sim $uid"

# hand over to user
interact
