Esempio n. 1
0
        public void getMacAddr()
        {
            string dat = Encoding.UTF8.GetString(w.DownloadData(ipAddr + "/get_status.cgi"));

            string[] split    = dat.Split(new string[] { "var" }, StringSplitOptions.None);
            string   foundMac = "";
            bool     isFound  = false;

            foreach (string s in split)
            {
                if (s.Contains("id="))
                {
                    foundMac = s.Substring(5, 12);
                    foundMac = Regex.Replace(foundMac, @"[^\u0000-\u007F]+", string.Empty);
                    isFound  = true;
                }
            }
            if (isFound)
            {
                macAddr = foundMac;
                print(Color.Green, "Mac is known: " + foundMac);
            }
            else
            {
                macAddr = "err";
                print(Color.Red, "Mac could not be located.");
            }
        }
Esempio n. 2
0
 public bool checkVuln()
 {
     try
     {
         w.DownloadData(ipAddr + "/Security/users" + secret_key);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 3
0
        public void updateDisplayRemote()
        {
            TimeWebClient w = new TimeWebClient();

            for (; ;)
            {
                st.Start();
                byte[] data = w.DownloadData(setUri);
                using (var ms = new MemoryStream(data))
                {
                    extBitmap = new Bitmap(ms);
                }
                this.Invoke(new MethodInvoker(delegate()
                {
                    this.Text         = rawTitle + prevTime + "ms";
                    pictureBox1.Image = extBitmap;
                }));
                st.Stop();
                prevTime = (int)st.ElapsedMilliseconds;
                st.Reset();
                Console.WriteLine("Got frame");
                Thread.Sleep(250);
            }
        }
Esempio n. 4
0
        public void mainTestThread(int thrid, List <String> ips, camData cdat, string dir, bool DoIpTag)
        {
            string thridAsText = "[" + thrid + "] ";

            cPrint(Color.Black, thridAsText + "Starting thread");

            List <String> goodIps = new List <String> {
            };
            TimeWebClient wc      = new TimeWebClient();

            wc.Credentials = cdat.Creds;

            foreach (string ip in ips)
            {
                //if the viewer form doesnt exist, exit the thread#
                if (killSwitch)
                {
                    //cPrint(Color.Red, thridAsText + "Close given! Killing myself!");
                    //break;
                }
                if (!this.IsHandleCreated)
                {
                    cPrint(Color.Red, thridAsText + "Handle lost! Killing myself!");
                    break;
                }

                remoteTestcounter++;
                this.Invoke(new MethodInvoker(delegate()
                {
                    BarMain.Value = remoteTestcounter;
                    this.Text     = "Viewer | Progress: " + remoteTestcounter + "/" + ipaCount;
                }));
                try
                {
                    string intIp = ip;

                    if (intIp.EndsWith(":"))
                    {
                        intIp = intIp.Substring(0, intIp.Length - 1);
                    }

                    byte[] dlData = wc.DownloadData("http://" + intIp + cdat.Path);
                    cPrint(Color.DarkGreen, thridAsText + ip + " | 200");

                    Bitmap   bmp;
                    Graphics g;
                    using (var ms = new MemoryStream(dlData))
                    {
                        bmp = new Bitmap(ms);
                    }


                    if (normalising)
                    {
                        Bitmap tmp = new Bitmap(bmp, setAR.width, setAR.height);
                        bmp = new Bitmap(tmp);
                        tmp.Dispose();
                    }

                    g = Graphics.FromImage(bmp);

                    String combinedCredsPT = cdat.Creds.UserName + " : " + cdat.Creds.Password;
                    SizeF  sizeOfIp        = g.MeasureString(intIp, luc);
                    SizeF  sizeOfCreds     = g.MeasureString(combinedCredsPT, luc);
                    int    totalheight     = (int)sizeOfIp.Height + (int)sizeOfCreds.Height;
                    int    largerWidth;
                    if (sizeOfIp.Width > sizeOfCreds.Width)
                    {
                        largerWidth = (int)sizeOfIp.Width;
                    }
                    else
                    {
                        largerWidth = (int)sizeOfCreds.Width;
                    }
                    totalheight += 3;
                    largerWidth += 3;

                    if (DoIpTag)
                    {
                        if (style == ipStyle.fancy || style == ipStyle.basic)
                        {
                            g.DrawImage(gHandle.generateStamp(intIp, combinedCredsPT, luc, bmp.Width, timestamp, style), 2, 2);
                        }
                        else if (style == ipStyle.barTop)
                        {
                            Bitmap   stamp = gHandle.generateStamp(intIp, combinedCredsPT, luc, bmp.Width, timestamp, style);
                            Bitmap   temp  = new Bitmap(bmp.Width, bmp.Height + stamp.Height);
                            Graphics gtemp = Graphics.FromImage(temp);
                            gtemp.DrawImage(stamp, 0, 0);
                            gtemp.DrawImage(bmp, 0, stamp.Height);

                            bmp = new Bitmap(temp);

                            stamp.Dispose();
                            temp.Dispose();
                            gtemp.Dispose();
                            GC.Collect();
                        }
                        else if (style == ipStyle.barBottom)
                        {
                            Bitmap   stamp = gHandle.generateStamp(intIp, combinedCredsPT, luc, bmp.Width, timestamp, style);
                            Bitmap   temp  = new Bitmap(bmp.Width, bmp.Height + stamp.Height);
                            Graphics gtemp = Graphics.FromImage(temp);
                            gtemp.DrawImage(bmp, 0, 0);
                            gtemp.DrawImage(stamp, 0, bmp.Height);

                            bmp = new Bitmap(temp);

                            stamp.Dispose();
                            temp.Dispose();
                            gtemp.Dispose();
                            GC.Collect();
                        }

                        gHandle.tidy();
                    }
                    else
                    {
                        //not using the graphics object causes System.Runtime.InteropServices.ExternalException
                        g.FillRectangle(Brushes.Black, -1, -1, 1, 1);
                    }

                    remoteSaveCounter++;
                    workingIps.Add(ip);
                    int rscLen = remoteSaveCounter.ToString().Length;

                    string ipSafe = ip.Replace(".", "-");
                    ipSafe = ipSafe.Replace(":", "-");

                    Console.WriteLine(bmp.GetType().Name);

                    string saveName = "";

                    if (anonFileNames)
                    {
                        saveName = RandomString(15) + ".jpg";
                    }
                    else
                    {
                        saveName = RandomString(5) + "-" + ipSafe + ".jpg";
                    }

                    if (useOutDir)
                    {
                        File.WriteAllLines(outdir, workingIps);
                    }

                    shiftReg.Insert(0, new shiftItem(bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height), PixelFormat.DontCare), saveName, intIp));
                    mainPB.Image     = shiftReg[0].img;
                    subPBone.Image   = shiftReg[1].img;
                    subPBtwo.Image   = shiftReg[2].img;
                    subPBthree.Image = shiftReg[3].img;
                    subPBfour.Image  = shiftReg[4].img;
                    subPBfive.Image  = shiftReg[5].img;
                    subPBsix.Image   = shiftReg[6].img;

                    Bitmap save = bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height), PixelFormat.DontCare);
                    save.Save(dir + "/" + saveName, ImageFormat.Jpeg);
                    cPrint(Color.DarkGreen, thridAsText + "Wrote " + new FileInfo(dir + "/" + saveName).Length + " bytes to disk");

                    if (shiftReg.Count > 8)
                    {
                        shiftReg.RemoveRange(8, shiftReg.Count - 8);
                    }

                    save.Dispose();
                    bmp.Dispose();
                    g.Dispose();
                    GC.Collect();
                }
                catch (WebException ex)
                {
                    if (ex.Status == WebExceptionStatus.ProtocolError)
                    {
                        var response = ex.Response as HttpWebResponse;
                        if (response != null)
                        {
                            cPrint(Color.Gray, thridAsText + ip + " | " + (int)response.StatusCode);
                        }
                        else
                        {
                            cPrint(Color.Gray, thridAsText + ip + " | Null");
                        }
                    }
                    else
                    {
                        cPrint(Color.Gray, thridAsText + ip + " | Down");
                    }
                }
                catch
                {
                    //sometimes ThreadAbortException is thrown when killing threads, dont show any errors after killswitch is triggered.
                    if (!killSwitch)
                    {
                        cPrint(Color.Red, thridAsText + ip + " | Internal error");
                    }
                }
            }
            deadThreads++;
            cPrint(Color.Black, thridAsText + "Reaching end. Thread will exit.");
        }