pkgname=iou pkgver=1.2 pkgrel=1 pkgdesc="Cisco IOU" arch=("any") url="http://www.cisco.com/" license=("custom") depends=("libpcap" "cryptsetup" "lib32-openssl" "perl-net-pcap") options=("emptydirs") install="${pkgname}.install" source=("${pkgname}.install" "iou2net.pl" "CiscoIOUKeygen.py" "IOUsniffer.tar.gz" "wrapper-linux.tar.gz" "i86bi_linux-adventerprisek9-ms.152-2.15.T" "i86bi_linux_l2-ipbasek9-ms.jan24-2013-team_track") build() { cd "${srcdir}/IOUsniffer" && make || return 1 cd "${srcdir}/wrapper-linux" && make || return 1 } package() { install -Dm 0755 "${srcdir}/iou2net.pl" "${pkgdir}/usr/bin/iou-live" install -Dm 0755 "${srcdir}/CiscoIOUKeygen.py" "${pkgdir}/usr/bin/iou-keygen" install -Dm 0755 "${srcdir}/IOUsniffer/iousniff" "${pkgdir}/usr/bin/iou-sniff" install -Dm 0755 "${srcdir}/wrapper-linux/wrapper-linux" "${pkgdir}/usr/bin/iou-wrapper" install -Dm 0755 "${srcdir}/i86bi_linux-adventerprisek9-ms.152-2.15.T" "${pkgdir}/usr/bin/iou-router" install -Dm 0755 "${srcdir}/i86bi_linux_l2-ipbasek9-ms.jan24-2013-team_track" "${pkgdir}/usr/bin/iou-switch" install -dm 0755 "${pkgdir}/usr/lib32/" ln -s "/usr/lib32/libcrypto.so.1.0.0" "${pkgdir}/usr/lib32/libcrypto.so.4" } md5sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP')
post_install() { grep xml.cisco.com /etc/hosts > /dev/null if [ $? -ne 0 ] then echo '127.0.0.127 xml.cisco.com' >> /etc/hosts fi /usr/bin/iou-keygen } post_upgrade() { grep xml.cisco.com /etc/hosts > /dev/null if [ $? -ne 0 ] then echo '127.0.0.127 xml.cisco.com' >> /etc/hosts fi } post_remove() { grep xml.cisco.com /etc/hosts > /dev/null if [ $? -ne 1 ] then sed -i '/xml.cisco.com/d' /etc/hosts fi }
#!/bin/bash WRAPPER="/usr/bin/iou-wrapper" ROUTER="/usr/bin/iou-router" SWITCH="/usr/bin/iou-switch" IOUSNIFF="/usr/bin/iou-sniff" DUMPDIR="./dump" DUMPDIRTMP="${DUMPDIR}/tmp" DUMPFILE="${DUMPDIR}/dump-$(date +%F-%T).pcap" DELAY="5" MODE=${1:-"--help"} # Name Type ID Port Serial Ethernet DEVICES=( "R-01" "R" "1" "10001" "0" "1" "R-02" "R" "2" "10002" "0" "2" "R-03" "R" "3" "10003" "0" "1" "R-04" "R" "4" "10004" "0" "1" "R-05" "R" "5" "10005" "0" "2" "R-06" "R" "6" "10006" "0" "2" "R-07" "R" "7" "10007" "0" "2" "R-08" "R" "8" "10008" "0" "1" "R-09" "R" "9" "10009" "0" "1" "R-10" "R" "10" "10010" "0" "1" "R-11" "R" "11" "10011" "0" "1" "SW-12" "S" "12" "10012" "0" "1" "SW-13" "S" "13" "10013" "0" "1" "SW-14" "S" "14" "10014" "0" "1" "R-15" "R" "15" "10015" "0" "1" ) start-iou() { for ((index=0; index < ${#DEVICES[@]}/6; index++)) do if [ "X_${DEVICES[${index}*6+1]}" == "X_R" ] then ${WRAPPER} -m ${ROUTER} -p ${DEVICES[${index}*6+3]} -- \ -s ${DEVICES[${index}*6+4]} \ -e ${DEVICES[${index}*6+5]} ${DEVICES[${index}*6+2]} &> /dev/null & else ${WRAPPER} -m ${SWITCH} -p ${DEVICES[${index}*6+3]} -- \ -s ${DEVICES[${index}*6+4]} \ -e ${DEVICES[${index}*6+5]} ${DEVICES[${index}*6+2]} &> /dev/null & fi done } start-konsole() { touch ./tabs for ((index=0; index < ${#DEVICES[@]}/6; index++)) do echo "title: ${DEVICES[${index}*6]};; command: telnet localhost ${DEVICES[${index}*6+3]}" >> ./tabs done konsole --tabs-from-file ./tabs &> /dev/null rm ./tabs &> /dev/null } reset-konsole() { for ((index=0; index < ${#DEVICES[@]}/6; index++)) do sudo kill -SIGHUP $(fuser -n tcp ${DEVICES[${index}*6+3]} 2>&1 | awk '{print $2}') done } start-sniff() { [ -d ${DUMPDIR} ] || mkdir -p ${DUMPDIR} &> /dev/null mkdir -p "${DUMPDIRTMP}" &> /dev/null ${IOUSNIFF} -f -o -i /tmp/netio$(id -u) -n ./NETMAP -s ${DUMPDIRTMP} &> /dev/null & } stop() { ps -e | grep "${1}" | awk '{ print $1 }' | xargs sudo kill "-${2}" &> /dev/null } case "${MODE}" in --start) start-iou sleep ${DELAY} start-konsole ;; --stop) stop "iou" "SIGKILL" ;; --start-iou) start-iou ;; --start-konsole) start-konsole ;; --reset-konsole) reset-konsole ;; --start-sniff) start-sniff ;; --stop-sniff) stop "iou-sniff" "SIGINT" fdupes -d -N ${DUMPDIRTMP} &> /dev/null mergecap -w ${DUMPFILE} ${DUMPDIRTMP}/*.pcap rm -rf ${DUMPDIRTMP} &> /dev/null ;; --help|*) echo -e "\nUsage: ${0} [OPTIONS]" echo -e "\nOPTIONS:\n" echo -e "\t--start \t- Start" echo -e "\t--stop \t\t- Stop" echo -e "\t--start-iou \t- Start IOU" echo -e "\t--start-sniff \t- Start Sniff" echo -e "\t--stop-sniff \t- Stop Sniff" echo -e "\t--start-konsole - Start konsole" echo -e "\t--reset-konsole - Reset konsole" echo -e "\t--help \t\t- Help\n" ;; esac
# Name Type ID Port Serial Ethernet DEVICES=( "R-01" "R" "1" "10001" "0" "1" "R-02" "R" "2" "10002" "0" "2" "R-03" "R" "3" "10003" "0" "1" "R-04" "R" "4" "10004" "0" "1" "R-05" "R" "5" "10005" "0" "2" "R-06" "R" "6" "10006" "0" "2" "R-07" "R" "7" "10007" "0" "2" "R-08" "R" "8" "10008" "0" "1" "R-09" "R" "9" "10009" "0" "1" "R-10" "R" "10" "10010" "0" "1" "R-11" "R" "11" "10011" "0" "1" "SW-12" "S" "12" "10012" "0" "1" "SW-13" "S" "13" "10013" "0" "1" "SW-14" "S" "14" "10014" "0" "1" "R-15" "R" "15" "10015" "0" "1" )
Source: https://habr.com/ru/post/253272/
All Articles