Manuals and How To's > Manuals

HOW-TO: Setup an IRC command system

(1/1)

grinch:
Once you have connected to IRCD safely (see https://ininjas.com/forum/index.php?topic=1876.0 ), and setup PuTTY for automatic password prompt-less login (see https://ininjas.com/forum/index.php?topic=1922.0 ), you may wish to setup an IRC based command system.
This can be used for VERY QUICK access to commonly used functions, like turning firewalls and services on or off, rebooting, shutdowns, etc
It can be used to give others in the IRC #Channel access to commands and scripts you have setup
You can use your imagination here...

It is really just a simple script which I will share.
In MiRC

--- Code: ---Alt+R
--- End code ---
to open Remote scripts window
Make sure it is in the "Remote" tab of this window
File > New
Paste this in the blank script that opens


--- Code: ---on *:TEXT:*!command*:#Channel: {
  if ($2 == DO1) {
    /run -n plink.exe PuTTY-profile-0 /home/user/command <option>
    /msg #Channel Command Sent Message 0
  }
  if ($2 == DO2) {
    /run -n plink.exe PuTTY-profile-1 /home/user/command <option>
    /msg #Channel Command Sent Message 1
  }
}
--- End code ---

File > Save As, choose a name for this .mrc script
Click "OK" to close Remote script window

Edit "!command" to be the trigger you wish to use, shorter the better
"#Channel" should be edited to the channel you want to run this on
Edit "PuTTY-profile-0" or "PuTTY-profile-1" to the profile names you use, in PuTTY

This example script uses two triggers, for different options. These are the "DO1" and "DO2"

--- Code: ---!command DO1
--- End code ---
will run one option to the commend

--- Code: ---!command DO2
--- End code ---
will run the same command, on a different box, in this example.
You can also use it to run different commands, on the same box, depending on the PuTTY profile you choose.
You can edit these $2 triggers to w/e you wish. You can also use these like ON/OFF switches


--- Code: ---on *:TEXT:*!iptables*:#Channel: {
  if ($2 == ON) {
    /run -n plink.exe PuTTY-profile-0 /etc/init.d/iptables start
    /msg #Channel IPTables firewall ON
  }
  if ($2 == OFF) {
    /run -n plink.exe PuTTY-profile-0 /etc/init.d/iptables stop
    /msg #Channel IPTables firewall OFF
  }
}
--- End code ---

Some more examples:

--- Code: ---on *:TEXT:*!reboot*:#Channel: {
  if ($2 == BOX0) {
    /run -n plink.exe PuTTY-profile-0 /sbin/reboot
    /msg #Channel BOX0 rebooted
  }
  if ($2 == BOX1) {
    /run -n plink.exe PuTTY-profile-1 /sbin/reboot
    /msg #Channel BOX1 rebooted
  }
}
--- End code ---


--- Code: ---on *:TEXT:*!nmap*:#Channel: {
    /run -n plink.exe PuTTY-profile-0 /usr/local/bin/nmap $2
    /msg #Channel Box $2 being mapped
}
--- End code ---
Example usage:
--- Code: ---!nmap 192.168.1.2
--- End code ---
This will NOT return the nmap result to the channel, just start the process


--- Code: ---on *:TEXT:*!attack*:#Channel: {
    /run -n plink.exe PuTTY-profile-0 /usr/bin/attack.script $2
    /msg #Channel Box $2 being attacked
}
--- End code ---

You can really use your imagination here and make some really creative command scripts

Note: I keep PuTTY PuTTYgen and plink.exe all in the same dir, which is in my PATH. You may need to "path" them out in your script

Note: If you are the person loading this script into your mirc, YOU WILL NOT BE ABLE TO TRIGGER THESE YOURSELF. That is because you are you. This script is looking for "on text" events, which are from other users. Easily fixed by running the script in another MiRC (or possibly a bot, if you have one).

EDIT: FFS, I did not include the most important example, the reason I made this tutorial; DANTE!
Here is a sample of how you can control your dante proxy-net


--- Code: ---on *:TEXT:*!prx*:#iNinjas: {
  if ($2 == P0) {
    if ($3 == ON){
    /run -n plink.exe Proxy-profile-0 /etc/init.d/danted start
    /msg #iNinjas Danted proxy0 is ON
    }
    if ($3 == OFF) {
    /run -n plink.exe PuTTY-profile-0 /etc/init.d/danted stop
    /msg #iNinjas Danted proxy0 is OFF
    }
  }
if ($2 == P1) {
    if ($3 == ON){
    /run -n plink.exe Proxy-profile-1 /etc/init.d/danted start
    /msg #iNinjas Danted proxy1 is ON
    }
    if ($3 == OFF) {
    /run -n plink.exe PuTTY-profile-1 /etc/init.d/danted stop
    /msg #iNinjas Danted proxy1 is OFF
    }
  }
if ($2 == P2) {
    if ($3 == ON){
    /run -n plink.exe Proxy-profile-2 /etc/init.d/danted start
    /msg #iNinjas Danted proxy2 is ON
    }
    if ($3 == OFF) {
    /run -n plink.exe PuTTY-profile-2 /etc/init.d/danted stop
    /msg #iNinjas Danted proxy2 is OFF
    }
  }
if ($2 == P3) {
    if ($3 == ON){
    /run -n plink.exe Proxy-profile-3 /etc/init.d/danted start
    /msg #iNinjas Danted proxy3 is ON
    }
    if ($3 == OFF) {
    /run -n plink.exe PuTTY-profile-3 /etc/init.d/danted stop
    /msg #iNinjas Danted proxy3 is OFF
    }
  }
if ($2 == P4) {
    if ($3 == ON){
    /run -n plink.exe Proxy-profile-4 /etc/init.d/danted start
    /msg #iNinjas Danted proxy4 is ON
    }
    if ($3 == OFF) {
    /run -n plink.exe PuTTY-profile-4 /etc/init.d/danted stop
    /msg #iNinjas Danted proxy4 is OFF
    }
  }
}
--- End code ---

This will control 5 proxies. It triggers off of !prx, and uses 2 terms as variables. The first variable, term #2 ($2) is the proxy identifier. The second variable, term #3 ($3) is on or off
Used like this:

--- Code: ---!prx p0 on
--- End code ---

--- Code: ---!prx p4 off
--- End code ---

You could write a command to bring all proxies up or down, as well.

Anything you can do in shell script can now be done through this command system. Use your imagination!

Ironman:
WOW!! Nice!! +1!!

grinch:
Thank you

I did not list is as an example, but this can be used to bring up or take down your remote "dante" proxies all over the world. It is a pre-cursor to the "dante-web" setup

Ironman:
Nice!!

Navigation

[0] Message Index

Go to full version