From e323522302e0f1f50f06b8236cd785e1371f8943 Mon Sep 17 00:00:00 2001 From: Victoria Guevara Date: Fri, 13 Jul 2018 23:05:06 +0300 Subject: [PATCH] Add files via upload --- checker/checker.boo | 73 +++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/checker/checker.boo b/checker/checker.boo index 70ae15f..7e6c502 100644 --- a/checker/checker.boo +++ b/checker/checker.boo @@ -1,5 +1,5 @@ # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -# AntiEye webcam checker v0.01 +# AntiEye webcam checker v0.03 # Developed in 2018 by Guevara-chan. # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- @@ -7,11 +7,8 @@ import System import System.IO import System.Drawing import System.Windows.Forms -import System.Threading.Tasks +import System.Text.RegularExpressions import System.Runtime.CompilerServices -import Emgu.CV from Emgu.CV.World -import Emgu.CV.Structure - #.{ [Classes] class CUI(): @@ -21,7 +18,7 @@ class CUI(): def constructor(): dbg("") log("""# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # - # AntiEye webcam checker v0.02 # + # AntiEye webcam checker v0.03 # # Developed in 2018 by V.A. Guevara # # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #""".Replace('\t', ''), "meta") @@ -58,8 +55,8 @@ class DirReport(): return "$dest/$fname" # -------------------- # class Checker(): - log = {info, channel|info = ":I Am Dummy:"; return self} - dbg = {info|info = ":I am Error:"; return self} + log = {info, channel|info = ':I Am Dummy:'; return self} + dbg = {info|info = ':I am Error:'; return self} tasks = Collections.Generic.Dictionary[of String, bool]() final tension_limit = 15 reporter as Type @@ -71,17 +68,15 @@ class Checker(): reporter = storage def parse(entry as string): - host, port, user, pword = entry.Split(char(':'), char(' ')) - return Uri("http://$(Uri.EscapeDataString(user)):$(Uri.EscapeDataString(pword))@$host:$port") - - def videocap(url as Uri): - user, password = url.UserInfo.Split(char(':')) - if (cap = VideoCapture("$(url)/videostream.cgi?loginuse=$(user)&loginpas=$(password)")).IsOpened: - return cap.QueryFrame().ToImage[of Bgr, byte](false).ToBitmap() + entry = Regex(" ").Replace(entry, '\n', 1) + if Regex.Matches(entry, ":").Count == 2 and Regex.Matches(entry, "\n").Count == 1: + host, port, user, pword = entry.Split(char(':'), char('\n')) + return Uri("http://$(Uri.EscapeDataString(user)):$(Uri.EscapeDataString(pword))@$host:$port") def check(url as Uri, dest as duck): - frame = WebBrowser(Width: 700, Height: 700, ScriptErrorsSuppressed: true) - frame.Navigate(url) + frame = WebBrowser(Width: 680, Height: 510, ScriptErrorsSuppressed: true) + user, password = url.UserInfo.Split(char(':')) + frame.Navigate("$(url)snapshot.cgi?user=$(user)&pwd=$(password)") frame.DocumentCompleted += checker(url, dest) log("Launching check for $url", 'launch').tasks.Add(url.ToString(), true) return self @@ -92,27 +87,26 @@ class Checker(): # Error checkup. # TO BE DONE ! # Down checkup. - if "res://ieframe.dll/ErrorPageTemplate.css" in sender.DocumentText: - dest.echo(url, "fail") - return log("Unable to load $url", "fail") - # Screenshot prepration. - bmp as Bitmap - cap = Task.Run({bmp = videocap(url)}) - cap.Wait(15000) - unless bmp: - bmp = Bitmap(sender.Width, sender.Height) - sender.DrawToBitmap(bmp, Rectangle(0, 0, bmp.Width, bmp.Height)) + if 'res://ieframe.dll/ErrorPageTemplate.css' in sender.DocumentText: + dest.echo(url, 'fail') + return log("Unable to load $url", 'fail') # Screenshot init. - using out = Graphics.FromImage(bmp): - login = url.UserInfo - rect = Rectangle(start = Point(5, 5), TextRenderer.MeasureText(login, font = Font("Sylfaen", 11))) - out.FillRectangle(SolidBrush(Color.Black), rect) - out.DrawRectangle(Pen(forecolor = Color.Coral, 1), rect) - out.DrawString(login, font, SolidBrush(forecolor), start) - shot = dest.store(bmp, "$(url.Host)[$(url.Port)].png") + using bmp = Bitmap(sender.Width - 20, sender.Height): + sender.DrawToBitmap(bmp, Rectangle(0, 0, bmp.Width, bmp.Height)) + #try: bmp = bmp.Clone(Rectangle(10, 15, bmp.Width - 30, bmp.Height - 10), bmp.PixelFormat) + #except ex: print ex + + using out = Graphics.FromImage(bmp): + login = url.UnescapeDataString(url.UserInfo) + rect = Rectangle(start = Point(5, 5), out.MeasureString(login, font = Font('Sylfaen', 11)).ToSize()) + rect.Width += 2 + out.FillRectangle(SolidBrush(Color.Black), rect) + out.DrawRectangle(Pen(forecolor = Color.Coral, 1), rect) + out.DrawString(login, font, SolidBrush(forecolor), start) + shot = dest.store(bmp, "$(url.Host)[$(url.Port)].png") # Finalization. - log("$shot was taken from $url", "success") - dest.echo(url, "success") + log("$shot was taken from $url", 'success') + dest.echo(url, 'success') def wait(max_tension as int): while tension > max_tension: Application.DoEvents() @@ -130,14 +124,15 @@ class Checker(): set: try: dest = reporter(value) - log("\nParsing '$value'...", "io") + log("\nParsing '$value'...", 'io') for entry in File.ReadLines(value): - check(parse(entry), dest).dbg(" [$tension/$(tension_limit+1)]").wait(tension_limit) + if (url = parse(entry)): check(url, dest).dbg(" [$tension/$(tension_limit+1)]").wait(tension_limit) + else: log("Invalid entry encountered: $entry", 'fault') wait(0) except ex: log("$ex", 'fault') #.} # ==Main code== [STAThread] def Main(argv as (string)): - Checker(CUI(), DirReport).feed = (argv[0] if argv.Length else "feed.txt") + Checker(CUI(), DirReport).feed = (argv[0] if argv.Length else 'feed.txt') Threading.Thread.Sleep(3000) \ No newline at end of file