-
Notifications
You must be signed in to change notification settings - Fork 2
/
hostlookup.php
53 lines (43 loc) · 1.62 KB
/
hostlookup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/*
REQUIREMENTS
* A custom slash command on a Slack team
* A web server running PHP5 with cURL enabled
USAGE
* Place this script on a server running PHP5 with cURL.
* Set up a new custom slash command on your Slack team:
http://my.slack.com/services/new/slash-commands
* Under "Choose a command", enter whatever you want for
the command. /dns is easy to remember.
* Under "URL", enter the URL for the script on your server.
* Leave "Method" set to "Post".
* Decide whether you want this command to show in the
autocomplete list for slash commands.
* If you do, enter a short description and usage hint.
*/
# Grab some of the values from the slash command, create vars for post back to Slack
$command = $_POST['command'];
$text = $_POST['text'];
$token = $_POST['token'];
# Check the token and make sure the request is from our team
if($token !='Md2ml70QrR7yabxW6vq6HxIU'){ #replace this with the token from your slash command configuration page
$msg = "The token for the slash command doesn't match. Check your script.";
die($msg);
echo $msg;
}
$user_agent = "Slack/1.0";
# We want to get the JSON version back (you can also get plain text).
$url_to_check = "http://api.hackertarget.com/hostsearch/?q=".$text;
# Set up cURL
$ch = curl_init($url_to_check);
# Set up options for cURL
# We want to get the value back from our query
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
# Send in our user agent string
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
# Make the call and get the response
$ch_response = curl_exec($ch);
# Close the connection
curl_close($ch);
# Send the reply back to the user.
echo $ch_response;