Skip to content
Browse files

Add a script for DNS requests

  • Loading branch information...
1 parent 1a6e5df commit 703a05f12bde371a6fc968c93099e8b172660aa8 @Geal committed Feb 22, 2013
Showing with 25 additions and 1 deletion.
  1. +24 −0 dns/dns
  2. +1 −1 index
View
24 dns/dns
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+if [ "$#" -ne 1 ]
+then
+ echo '{ "version": 1, "title": "DNS", "type":"status", "status":"error", "message":"Please enter a domain" }';
+else
+ IFS=$'\n'$'\r'
+ arr=( $(host $1 2>/dev/null) );
+ if [ $? != 0 ]
+ then
+ echo '{ "version": 1, "title": "DNS", "type":"status", "status":"error", "message":"Please enter a valid domain" }';
+ else
+ echo "{ \"version\": 1, \"title\": \"DNS\", \"type\":\"commands\", \"values\" : [ { \"name\" : \"FQDN\", \"value\" : \"$1\", \"command\" : \"\"}";
+ for line in "${arr[@]}"; do
+ regex='has address (.*)'
+ if [[ "$line" =~ $regex ]] ; then echo ",{\"name\": \"IP\", \"value\":\"${BASH_REMATCH[1]}\"}"; fi
+ regex2='mail is handled by (.*)'
+ if [[ "$line" =~ $regex2 ]] ; then echo ",{\"name\": \"Mail\", \"value\":\"${BASH_REMATCH[1]}\"}"; fi
+ regex3='has IPv6 address (.*)'
+ if [[ "$line" =~ $regex3 ]] ; then echo ",{\"name\": \"IPv6\", \"value\":\"${BASH_REMATCH[1]}\"}"; fi
+ done
+ echo " ] }";
+ fi
+fi
View
2 index
@@ -1,3 +1,3 @@
#!/bin/bash
-echo '{ "version": 1, "title": "Commands", "type":"commands", "values" : [ {"name" : "Process list", "value" : "", "command" : ".pilotssh/process/process.sh" }, {"name" : "Apache services", "value" : "", "command" : ".pilotssh/apache/apache.sh" }, { "name" : "Logs", "value" : "", "command" : ".pilotssh/logs/logs.sh"}, { "name" : "Power", "value" : "", "command" : ".pilotssh/power/power.sh"}, {"name" : "Echo", "value" : "", "command" : ".pilotssh/echo/echo.sh", "query": "Echo?" },{ "name" : "WordPress", "value" : "", "command" : ".pilotssh/wordpress/wordpress.php"}, { "name" : "Network interfaces", "value" : "", "command" : ".pilotssh/network/network.py"} ] }';
+echo '{ "version": 1, "title": "Commands", "type":"commands", "values" : [ {"name" : "Process list", "value" : "", "command" : ".pilotssh/process/process.sh" }, {"name" : "Apache services", "value" : "", "command" : ".pilotssh/apache/apache.sh" }, { "name" : "Logs", "value" : "", "command" : ".pilotssh/logs/logs.sh"}, { "name" : "Power", "value" : "", "command" : ".pilotssh/power/power.sh"}, {"name" : "Echo", "value" : "", "command" : ".pilotssh/echo/echo.sh", "query": "Echo?" },{ "name" : "WordPress", "value" : "", "command" : ".pilotssh/wordpress/wordpress.php"}, { "name" : "Network interfaces", "value" : "", "command" : ".pilotssh/network/network.py"}, {"name": "DNS", "value":"", "command": ".pilotssh/dns/dns", "query": "Enter a domain"} ] }';

0 comments on commit 703a05f

Please sign in to comment.
Something went wrong with that request. Please try again.