Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            RestApi search = new RestApi();

            //https://api.shodan.io/shodan/host/{ip}?key={YOUR_API_KEY}
            search.endpoint = RestApi.baseUrl + "host/" + ipTxt.Text + "?key=" + RestApi.apiKey + "&minify=true";
            string response = search.makeRequest();
            //convert the response json array into dictionery then display it
            Dictionary <string, object> x = JsonConvert.DeserializeObject <Dictionary <string, object> >(response);
            string temp1 = string.Empty;
            Int64  temp2 = 1;

            try
            {
                foreach (var item in x)
                {
                    if (item.Value != null)//shouldn't display null values or non (string / integer) values
                    {
                        string key = (item.Key), value = (item.Value.ToString());
                        if (item.Value.GetType() == temp1.GetType() || item.Value.GetType() == temp2.GetType())
                        {
                            debugOutput(key + " : " + value);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void ports_Load(object sender, EventArgs e)
        {
            //This method returns a list of port numbers that the crawlers are looking for.
            RestApi ports = new RestApi();

            //https://api.shodan.io/shodan/ports?key={YOUR_API_KEY}
            ports.endpoint = RestApi.baseUrl + "ports?key=" + RestApi.apiKey;
            string response = ports.makeRequest();

            //remove unneccassry [] and split json array into array of string
            string[] portsTotal = Format(response).Split(',');
            label2.Text = portsTotal.Length.ToString() + " total ports";
            //show ports
            for (int i = 0; i < portsTotal.Length; i++)
            {
                debugOutput(portsTotal[i]);
            }
        }
Exemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            textBox2.Text = "";
            //Search Shodan using the same query syntax as the website
            RestApi search = new RestApi();
            string  query  = string.Empty;
            //group query pairs(property:value) from textboxes
            bool used = false;

            if (devicetxt.Text.ToString() != "")
            {
                query += devicetxt.Text;
                used   = true;
            }
            if (countrytxt.Text.ToString() != "")
            {
                if (used)
                {
                    query += "%20";
                }
                query += "country:" + countrytxt.Text;
                used   = true;
            }
            if (citytxt.Text.ToString() != "")
            {
                if (used)
                {
                    query += "%20";
                }
                query += "city:" + citytxt.Text;
                used   = true;
            }
            if (isptxt.Text.ToString() != "")
            {
                if (used)
                {
                    query += "%20";
                }
                used   = true;
                query += "isp:" + isptxt.Text;
            }
            if (porttxt.Text.ToString() != "")
            {
                if (used)
                {
                    query += "%20";
                }
                used   = true;
                query += "port:" + porttxt.Text;
            }
            if (ostxt.Text.ToString() != "")
            {
                if (used)
                {
                    query += "%20";
                }
                used   = true;
                query += "os:" + ostxt.Text;
            }
            //https://api.shodan.io/shodan/host/search?key={YOUR_API_KEY}&query={query}
            search.endpoint = RestApi.baseUrl + "host/search?key=" + RestApi.apiKey + "&query=" + query;
            string response = search.makeRequest();
            Dictionary <string, object> x = JsonConvert.DeserializeObject <Dictionary <string, object> >(response);
            //the dictionry has 2 keys [total = > total number found , matches = > devices details]
            string tempelate = filter(x["matches"].ToString());

            if (int.Parse(x["total"].ToString()) != 0)//if we found at least one or more device
            {
                try {
                    //filter resoonse json and split into string array
                    String[] all = filter2(filter(x["matches"].ToString()), int.Parse(x["total"].ToString()));
                    for (int i = 0; i < all.Length; i++)
                    {
                        debugOutput("*********DEVICE*********");
                        Dictionary <string, object> data = JsonConvert.DeserializeObject <Dictionary <string, object> >(all[i]);
                        if (data.ContainsKey("ip_str"))
                        {
                            debugOutput("ip :  " + data["ip_str"]);
                        }
                        if (data.ContainsKey("product"))
                        {
                            debugOutput("product :  " + data["product"]);
                        }
                        if (data.ContainsKey("os"))
                        {
                            debugOutput("operating system :  " + data["os"]);
                        }
                        if (data.ContainsKey("server"))
                        {
                            debugOutput("server :  " + data["server"]);
                        }
                        if (data.ContainsKey("isp"))
                        {
                            debugOutput("internet service provider :  " + data["isp"]);
                        }
                        if (data.ContainsKey("org"))
                        {
                            debugOutput("orgnaization :  " + data["org"]);
                        }
                        if (data.ContainsKey("port"))
                        {
                            debugOutput("port :  " + data["port"]);
                        }
                        if (data.ContainsKey("location"))
                        {
                            Dictionary <string, string> location = JsonConvert.DeserializeObject <Dictionary <string, string> >(data["location"].ToString());
                            if (location.ContainsKey("country_name"))
                            {
                                debugOutput("country :  " + location["country_name"]);
                            }
                            if (location.ContainsKey("city"))
                            {
                                debugOutput("city :  " + location["city"]);
                            }
                            if (location.ContainsKey("area_code"))
                            {
                                debugOutput("area code :  " + location["area_code"]);
                            }
                            if (location.ContainsKey("postal_code"))
                            {
                                debugOutput("postal code :  " + location["postal_code"]);
                            }
                            if (location.ContainsKey("country_code"))
                            {
                                debugOutput("country code :  " + location["country_code"]);
                            }
                            if (location.ContainsKey("longitude") && location.ContainsKey("latitude"))
                            {
                                debugOutput("location :  ");
                                debugOutput(location["latitude"] + " latitude and " + location["longitude"] + " longitude");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("error : " + ex.Message);
                }
                label8.Text = x["total"].ToString() + " devices found";
            }
            else
            {
                MessageBox.Show("No Results Found!");
            }
        }