Exemple #1
0
    print('Converting tiff images in', img_dir, 'to box files.')
    for f in sorted(os.listdir(img_dir)):
        if not is_file_of_type(f, 'tif'):
            continue
        f = os.path.join(img_dir, f)
        if not os.path.exists(change_ext(f, '.box')):
            tiff_to_box(banti_segmenter, f)


####################################### Load OCR
from ocr import OCR

print('Initializing the OCR')
recognizer = OCR(args.nnet_fname,
                 args.scaler_fname,
                 args.labels_fname,
                 args.ngram_fname,
                 args.calibration,
                 args.log_level)
print('Done')


####################################### Helpers

def ocr_box_dir(img_dir):
    print('Recognizing box files in ', img_dir)
    for f in sorted(os.listdir(img_dir)):
        if is_file_of_type(f, 'box'):
            f = os.path.join(img_dir, f)
            print('OCRing', f)
            recognizer.ocr_box_file(f)
Exemple #2
0
import cv2
import json
import base64
import numpy as np
from ocr import OCR
from aiohttp import web
from mrrest import RESTApi
from config import log

ocr = OCR()


def load_images(images: list):
    out = list()
    for image_encoded in images:
        image_bytes = base64.b64decode(image_encoded)
        image_array = np.frombuffer(image_bytes, np.uint8)
        out.append(cv2.imdecode(image_array, cv2.IMREAD_COLOR))
    return out


async def test(request: web.Request):
    try:
        request = await request.json()
    except json.JSONDecodeError:
        raise web.HTTPBadRequest(text='wrong json format')

    images = load_images(request['images'])
    log.info('Loaded images: {0}'.format(len(images)))
    result = ocr.process_images(images=images)
    return result
Exemple #3
0
    def attackIP(self, ip, max, mode):
        ut = Utils()
        info = self.myinfo()
        info = json.loads(info)
        uhash = info['uhash']
        if mode == "Secure":
            time.sleep(1)

        temp = ut.requestStringNoWait(
            "user::::pass::::uhash::::target",
            self.api.getUsername() + "::::" + self.api.getPassword() + "::::" +
            str(uhash) + "::::" + ip, "vh_loadRemoteData.php")
        jsons = json.loads(temp)

        o = OCR()
        imgs = o.getSolution(str(temp))
        if imgs != None:
            try:
                user = jsons['username']
                winchance = jsons['winchance']
            except TypeError:
                return False
            try:
                if winchance:
                    fwlevel = jsons['fw']
                    avlevel = jsons['av']
                    spamlevel = jsons['spam']
                    sdklevel = jsons['sdk']
                    ipsplevel = jsons['sdk']
                    money = jsons['money']
                    saving = jsons['savings']
                    anonymous = jsons['anonymous']
                    username = jsons['username']
                    winlo = jsons['winelo']
                    winchance = jsons['winchance']
                    spywarelevel = jsons['spyware']
                else:
                    avlevel = "????"
                    winchance = 0
                    print "no scan username"
                    return False

            except TypeError:
                fwlevel = jsons['fw']
                avlevel = jsons['av']
                spamlevel = jsons['spam']
                sdklevel = jsons['sdk']
                ipsplevel = jsons['sdk']
                money = jsons['money']
                saving = jsons['savings']
                anonymous = jsons['anonymous']
                username = jsons['username']
                winlo = jsons['winelo']
                winchance = jsons['winchance']
                spywarelevel = jsons['spyware']

            if type(winchance) == "str":
                if "?" in winchance:
                    winchance = 0
                    print "no chance"
                    return False

            if mode == "Potator":
                if winchance > 20:
                    password = self.enterPassword(imgs, ip, uhash)
                    jsons = json.loads(password)
                    if password:
                        try:
                            if not "?" in str(money) and str(
                                    jsons['result']) == 0:
                                print "\n[TargetIP: " + str(
                                    ip) + "]\n\nMade " + "{:11,}".format(
                                        int(jsons['amount'])
                                    ) + " and " + "{:2d}".format(
                                        int(jsons['eloch'])
                                    ) + " Rep." + "\n Antivirus: " + str(
                                        avlevel) + " Firewall: " + str(
                                            fwlevel
                                        ) + " Sdk: " + str(
                                            sdklevel
                                        ) + " TotalMoney: " + "{:11,}".format(
                                            int(money)
                                        ) + "\n YourWinChance: " + str(
                                            winchance) + " Anonymous: " + str(
                                                anonymous
                                            ) + " username: "******" saving: " + str(
                                                    saving) + "\n"
                                return True
                            else:
                                print "\n[TargetIP: " + str(
                                    ip) + "]\n\nMade " + "{:11,}".format(
                                        int(jsons['amount'])
                                    ) + " and " + "{:2d}".format(
                                        int(jsons['eloch'])
                                    ) + " Rep." + "\n Antivirus: " + str(
                                        avlevel) + " Firewall: " + str(
                                            fwlevel) + " Sdk: " + str(
                                                sdklevel
                                            ) + " TotalMoney: " + str(
                                                money
                                            ) + "\n YourWinChance: " + str(
                                                winchance
                                            ) + " Anonymous: " + str(
                                                anonymous
                                            ) + " username: "******" saving: " + str(
                                                    saving) + "\n"
                                return True

                        except KeyError:
                            print "Bad attack"
                            return False

                        except ValueError as e:
                            print "error"
                            return True
                    else:
                        print "Password Wrong"
                        return False
                else:
                    print "winchance is poor: " + str(winchance)
                    return False

            if not "?" in str(avlevel) and not "?" in str(
                    winchance) and mode == "Secure":
                if int(avlevel) < max and int(winchance) > 75 and str(
                        anonymous) == "YES":
                    time.sleep(random.randint(2, 3))
                    password = self.enterPassword(imgs, ip, uhash)
                    jsons = json.loads(password)
                    if password:
                        try:
                            if not "?" in str(money) and str(
                                    jsons['result']) == 0:
                                print "\n[TargetIP: " + str(
                                    ip) + "]\n\nMade " + "{:11,}".format(
                                        int(jsons['amount'])
                                    ) + " and " + "{:2d}".format(
                                        int(jsons['eloch'])
                                    ) + " Rep." + "\n Antivirus: " + str(
                                        avlevel) + " Firewall: " + str(
                                            fwlevel
                                        ) + " Sdk: " + str(
                                            sdklevel
                                        ) + " TotalMoney: " + "{:11,}".format(
                                            int(money)
                                        ) + "\n YourWinChance: " + str(
                                            winchance) + " Anonymous: " + str(
                                                anonymous
                                            ) + " username: "******" saving: " + str(
                                                    saving) + "\n"
                                return True
                            else:
                                print "\n[TargetIP: " + str(
                                    ip) + "]\n\nMade " + "{:11,}".format(
                                        int(jsons['amount'])
                                    ) + " and " + "{:2d}".format(
                                        int(jsons['eloch'])
                                    ) + " Rep." + "\n Antivirus: " + str(
                                        avlevel) + " Firewall: " + str(
                                            fwlevel) + " Sdk: " + str(
                                                sdklevel
                                            ) + " TotalMoney: " + str(
                                                money
                                            ) + "\n YourWinChance: " + str(
                                                winchance
                                            ) + " Anonymous: " + str(
                                                anonymous
                                            ) + " username: "******" saving: " + str(
                                                    saving) + "\n"
                                return True

                        except KeyError:
                            print "Bad attack"
                            return False
                    else:
                        print "Password Wrong"
                        return False
                else:
                    #print "\n"
                    if int(avlevel) > max:
                        print "Antivir to high " + str(avlevel)
                        #print "passed"
                        return False
                    if int(winchance) < 75:
                        print "winchance is poor: " + str(winchance)
                        #print "passed"
                        return False
                    if str(anonymous) == "NO":
                        print "No Anonymous need"
                        #print "passed"
                        return False
            else:
                if len(avlevel) == 4:
                    print "Cant load User"
                    return False
                else:
                    print "Scan to low"
                    return False
        else:
            print "Password Error"
            return False
Exemple #4
0
 def attackIP2(self, ip, max):
     ut = Utils()
     o = OCR(False)
     imgs = self.requestPassword(ip)
     selection = o.getPassword(imgs)
     print selection
Exemple #5
0
def main(args):
    OCR(args)
    return 0
Exemple #6
0
 def __init__(self, gui):
     QThread.__init__(self)
     self.ocr = OCR(debug=False, gui=gui)
     self.ocr_thread = threading.Thread(name="ocr_thread",
                                        target=self.ocr.main)
Exemple #7
0
import sys,os
import urllib2
import json
import cv2
import numpy as np
import random
import time
from PIL import Image, ImageEnhance, ImageDraw, ImageFont 

#address="http://192.168.6.47:8089/upload"
#address="http://10.57.239.242:8089/upload"

from ocr import OCR
words_detect=OCR()

def imread_binary(img_buffer):
    img = np.asarray(bytearray(img_buffer), dtype='uint8')
    img = cv2.imdecode(img, cv2.IMREAD_COLOR)
    if len(img.shape) == 2 :
        img = img[:, :, np.newaxis]
        if color:
            img = np.tile(img, (1, 1, 3))
    elif len(img.shape) == 3 and img.shape[2] == 4:
        img = img[:, :, :3]
    return img

def draw_bbox(img, bboxes, color):
    bboxes=[bboxes]
    font = ImageFont.truetype('simkai.ttf', 14)
    img = Image.fromarray(img)
    draw = ImageDraw.Draw(img)
Exemple #8
0
 def tracker(self, txtProductNum, autoVerify=False):
     resource = self.get_resource()
     if not autoVerify:
         code = input('請輸入驗證碼: ')
     else:
         try:
             ocr = OCR(tesseract_cmd=self.tesseract_path)
             code = ocr.convert('./codeImg.jpg')
         except:
             raise Exception
     if not code:
         raise CodeNotFound('can\'t identify image.')
     payload = {
         '__LASTFOCUS': '',
         '__EVENTTARGET': '',
         '__EVENTARGUMENT': '',
         '__VIEWSTATE': resource['__VIEWSTATE'],
         '__VIEWSTATEGENERATOR': resource['__VIEWSTATEGENERATOR'],
         'txtProductNum': txtProductNum,
         'tbChkCode': code,
         'aaa': '',
         'txtIMGName': '',
         'txtPage': '1'
     }
     with requests.post(
             'https://eservice.7-11.com.tw/E-Tracking/search.aspx',
             headers=resource['headers'],
             data=payload,
             allow_redirects=False) as response:
         if response.status_code != 200:
             response.raise_for_status()
         body = BeautifulSoup(response.text, 'html.parser')
         if (body.find('input', {'id': 'txtPage'})['value']) == '2':
             info_children = body.find('div', {
                 'class': 'info'
             }).find_all('div', recursive=False)
             shipping = body.find('div', {'class': 'shipping'})
             pickup_info = info_children[0]
             #取貨門市
             store_name = pickup_info.find('span', {
                 'id': 'store_name'
             }).text
             #取貨門市地址
             store_address = pickup_info.find('p', {
                 'id': 'store_address'
             }).text
             #取貨截止日
             pickup_deadline = pickup_info.find('span', {
                 'id': 'deadline'
             }).text
             #付款資訊
             payment_type = info_children[1].find('h4', {
                 'id': 'servicetype'
             }).text
             #貨態資訊
             status = []
             for element in shipping.find_all('li'):
                 status_date = re.findall(r"\d{4}/\d{2}/\d{2} \d{2}:\d{2}",
                                          element.text)[0]
                 status.append(status_date + ' ' +
                               (element.text).replace(status_date, ''))
             status.reverse()
             tracker = {
                 '取貨門市': store_name,
                 '取貨門市地址': store_address,
                 '取貨截止日': pickup_deadline,
                 '付款資訊': payment_type,
                 '貨態資訊': status
             }
             return tracker
         raise VerifyError('Verify identify image error.')
    def attackIP(self, ip, max, mode):
        ut = Utils()
        info = self.myinfo()
        info = json.loads(info)
        uhash = info['uhash']
        temp = ut.requestString(
            "user::::pass::::uhash::::target",
            self.api.getUsername() + "::::" + self.api.getPassword() + "::::" +
            uhash + "::::" + ip, "vh_loadRemoteData.php")

        jsons = json.loads(temp)

        o = OCR()
        imgs = o.getSolution(str(temp))
        if imgs is not None:
            try:
                # user = jsons['username']
                winchance = jsons['winchance']
            except TypeError:
                return False
            try:
                if "?" not in str(winchance):
                    fwlevel = jsons['fw']
                    avlevel = jsons['av']
                    # spamlevel = jsons['spam']
                    sdklevel = jsons['sdk']
                    # ipsplevel = jsons['sdk']
                    money = jsons['money']
                    saving = jsons['savings']
                    anonymous = jsons['anonymous']
                    username = jsons['username']
                    # winlo = jsons['winelo']
                    winchance = jsons['winchance']
                    # spywarelevel = jsons['spyware']
                else:
                    avlevel = "????"
                    winchance = 0
                    print "no scan username"
                    return False

            except TypeError:
                fwlevel = jsons['fw']
                avlevel = jsons['av']
                # spamlevel = jsons['spam']
                sdklevel = jsons['sdk']
                # ipsplevel = jsons['sdk']
                money = jsons['money']
                saving = jsons['savings']
                anonymous = jsons['anonymous']
                username = jsons['username']
                # winlo = jsons['winelo']
                winchance = jsons['winchance']
                # spywarelevel = jsons['spyware']

            if type(winchance) == "int":
                if "?" in winchance:
                    winchance = 0
                    print "no chance"
                    return False

            if mode == "Potator":
                if winchance > 49:
                    password = self.enterPassword(imgs, ip, uhash)
                    jsons = json.loads(password)
                    if password:
                        try:
                            if "?" not in str(money) and str(
                                    jsons['result']) == 0:
                                print(
                                    "\n[TargetIP: {}]\n\nMade {:11,} and {:2d} Rep.\n Antivirus: {} Firewall: {} Sdk: {} TotalMoney: {:11,}\n YourWinChance: {} Anonymous: {} username: {} saving: {}"
                                    .format(ip, jsons['amount'],
                                            jsons['eloch'], avlevel, fwlevel,
                                            sdklevel, money, winchance,
                                            anonymous, username, saving))
                                return True
                            else:
                                print(
                                    "\n[TargetIP: {}]\n\nMade {:11,} and {:2d} Rep.\n Antivirus: {} Firewall: {} Sdk: {} TotalMoney: {:11,}\n YourWinChance: {} Anonymous: {} username: {} saving: {}"
                                    .format(ip, jsons['amount'],
                                            jsons['eloch'], avlevel, fwlevel,
                                            sdklevel, money, winchance,
                                            anonymous, username, saving))
                                return True

                        except KeyError:
                            print "Bad attack"
                            return False

                        except ValueError as e:
                            print "Error: " + e
                            return True
                    else:
                        print "Password Wrong"
                        return False
                else:
                    print "winchance is poor: " + str(winchance)

            if "?" not in str(avlevel) and mode == "Secure":
                if int(avlevel) < max and int(winchance) > 75 and str(
                        anonymous) == "YES":
                    password = self.enterPassword(imgs, ip, uhash)
                    jsons = json.loads(password)
                    if password:
                        try:
                            if "?" not in str(money) and str(
                                    jsons['result']) == 0:
                                print(
                                    "\n[TargetIP: {}]\n\nMade {:11,} and {:2d} Rep.\n Antivirus: {} Firewall: {} Sdk: {} TotalMoney: {:11,}\n YourWinChance: {} Anonymous: {} username: {} saving: {}"
                                    .format(ip, jsons['amount'],
                                            jsons['eloch'], avlevel, fwlevel,
                                            sdklevel, money, winchance,
                                            anonymous, username, saving))
                                return True
                            else:
                                print(
                                    "\n[TargetIP: {}]\n\nMade {:11,} and {:2d} Rep.\n Antivirus: {} Firewall: {} Sdk: {} TotalMoney: {:11,}\n YourWinChance: {} Anonymous: {} username: {} saving: {}"
                                    .format(ip, jsons['amount'],
                                            jsons['eloch'], avlevel, fwlevel,
                                            sdklevel, money, winchance,
                                            anonymous, username, saving))
                        except KeyError:
                            print "Bad attack"
                            return False
                    else:
                        print "Password Wrong"
                        return False
                else:
                    # print "\n"
                    if int(avlevel) > max:
                        print "Antivir to high " + str(avlevel)
                        # print "passed"
                        return False
                    if int(winchance) < 75:
                        print "winchance is poor: " + str(winchance)
                        # print "passed"
                        return False
                    if str(anonymous) == "NO":
                        print "No Anonymous needed"
                        # print "passed"
                        return False
            else:
                if len(avlevel) == 4:
                    print "Cant load User"
                    return False
                else:
                    print "Scan to low"
                    return False
        else:
            print "Password Error"
            return False
Exemple #10
0
    def attackIP(self, ip, max, mode):
        info = self.myinfo()
        info = json.loads(info)
        uhash = info['uhash']
        if mode == "Secure":
            time.sleep(1)

        temp = self.ut.requestString(
            "user::::pass::::uhash::::target", self.username + "::::" +
            self.password + "::::" + str(uhash) + "::::" + ip,
            "vh_loadRemoteData.php")
        jsons = json.loads(temp)

        o = OCR()
        imgs = o.getSolution(str(temp))
        if imgs != None:
            try:
                user = jsons['username']
                winchance = jsons['winchance']
            except TypeError:
                return False
            try:
                if winchance:
                    fwlevel = jsons['fw']
                    avlevel = jsons['av']
                    spamlevel = jsons['spam']
                    sdklevel = jsons['sdk']
                    ipsplevel = jsons['ipsp']
                    money = jsons['money']
                    saving = jsons['savings']
                    anonymous = jsons['anonymous']
                    username = jsons['username']
                    winlo = jsons['winelo']
                    winchance = jsons['winchance']
                    spywarelevel = jsons['spyware']
                else:
                    avlevel = "????"
                    winchance = 0
                    print "no scan username"
                    return False

            except TypeError:
                fwlevel = jsons['fw']
                avlevel = jsons['av']
                spamlevel = jsons['spam']
                sdklevel = jsons['sdk']
                ipsplevel = jsons['ipsp']
                money = jsons['money']
                saving = jsons['savings']
                anonymous = jsons['anonymous']
                username = jsons['username']
                winlo = jsons['winelo']
                winchance = jsons['winchance']
                spywarelevel = jsons['spyware']

            if type(winchance) == "str":
                if "?" in winchance:
                    winchance = 0
                    print "no chance"
                    return False

            if mode == "Potator":
                if winchance > 20:
                    password = self.enterPassword(imgs, ip, uhash)
                    jsons = json.loads(password)
                    if password:
                        try:
                            if not "?" in str(money) and str(
                                    jsons['result']) == 0:
                                print "\nYour Money: " + "{:11,}".format(
                                    int(jsons['newmoney'])
                                ) + "\n[TargetIP: " + str(
                                    ip) + "]\n\nMade " + "{:11,}".format(
                                        int(jsons['amount'])
                                    ) + " and " + "{:2d}".format(
                                        int(jsons['eloch'])
                                    ) + " Rep." + "\n Antivirus: " + str(
                                        avlevel) + " Firewall: " + str(
                                            fwlevel
                                        ) + " Sdk: " + str(
                                            sdklevel
                                        ) + " TotalMoney: " + "{:11,}".format(
                                            int(money)
                                        ) + "\n YourWinChance: " + str(
                                            winchance) + " Anonymous: " + str(
                                                anonymous
                                            ) + " username: "******" saving: " + str(
                                                    saving) + "\n"
                                try:
                                    ip = re.search(
                                        r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',
                                        username).group()
                                except AttributeError:
                                    pass
                                # print ip, type(ip), username, type(username)
                                s = requests.session()
                                if ip == username:
                                    print "send to database"
                                    s.get(
                                        "https://vhack.olympiccode.ga/database/submit.php?IP="
                                        + str(ip) + "&MONEY=" + str(money) +
                                        "&IPSP=" + str(ipsplevel) + "&FW=" +
                                        str(fwlevel) + "&AV=" + str(avlevel))
                                    s.close()
                                else:
                                    print "send to database"
                                    s.get(
                                        "https://vhack.olympiccode.ga/database/submit.php?IP="
                                        + str(ip) + "&USR="******"&MONEY=" + str(money) + "&IPSP=" +
                                        str(ipsplevel) + "&FW=" +
                                        str(fwlevel) + "&AV=" + str(avlevel))
                                    s.close()
                            else:
                                print "\nYour Money: " + "{:11,}".format(
                                    int(jsons['newmoney'])
                                ) + "\n[TargetIP: " + str(
                                    ip) + "]\n\nMade " + "{:11,}".format(
                                        int(jsons['amount'])
                                    ) + " and " + "{:2d}".format(
                                        int(jsons['eloch'])
                                    ) + " Rep." + "\n Antivirus: " + str(
                                        avlevel) + " Firewall: " + str(
                                            fwlevel) + " Sdk: " + str(
                                                sdklevel
                                            ) + " TotalMoney: " + str(
                                                money
                                            ) + "\n YourWinChance: " + str(
                                                winchance
                                            ) + " Anonymous: " + str(
                                                anonymous
                                            ) + " username: "******" saving: " + str(
                                                    saving) + "\n"
                                try:
                                    ip = re.search(
                                        r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',
                                        username).group()
                                except AttributeError:
                                    pass
                                # print ip, type(ip), username, type(username)
                                s = requests.session()
                                if ip == username:
                                    print "send to database"
                                    s.get(
                                        "https://vhack.olympiccode.ga/database/submit.php?IP="
                                        + str(ip) + "&MONEY=" + str(money) +
                                        "&IPSP=" + str(ipsplevel) + "&FW=" +
                                        str(fwlevel) + "&AV=" + str(avlevel))
                                    s.close()
                                else:
                                    print "send to database"
                                    s.get(
                                        "https://vhack.olympiccode.ga/database/submit.php?IP="
                                        + str(ip) + "&USR="******"&MONEY=" + str(money) + "&IPSP=" +
                                        str(ipsplevel) + "&FW=" +
                                        str(fwlevel) + "&AV=" + str(avlevel))
                                    s.close()

                                return True

                        except KeyError:
                            print "Bad attack"
                            return False

                        except ValueError as e:
                            print "error"
                            return True
                    else:
                        print "Password Wrong"
                        return False
                else:
                    print "winchance is poor: " + str(winchance)
                    return False

            if not "?" in str(avlevel) and not "?" in str(
                    winchance) and mode == "Secure":
                if int(avlevel) < max and int(winchance) > 75 and str(
                        anonymous) == "YES":
                    time.sleep(random.randint(2, 3))
                    password = self.enterPassword(imgs, ip, uhash)
                    jsons = json.loads(password)
                    if password:
                        try:
                            if not "?" in str(money) and str(
                                    jsons['result']) == 0:
                                print "\nYour Money: " + "{:11,}".format(
                                    int(jsons['newmoney'])
                                ) + "\n[TargetIP: " + str(
                                    ip) + "]\n\nMade " + "{:11,}".format(
                                        int(jsons['amount'])
                                    ) + " and " + "{:2d}".format(
                                        int(jsons['eloch'])
                                    ) + " Rep." + "\n Antivirus: " + str(
                                        avlevel) + " Firewall: " + str(
                                            fwlevel
                                        ) + " Sdk: " + str(
                                            sdklevel
                                        ) + " TotalMoney: " + "{:11,}".format(
                                            int(money)
                                        ) + "\n YourWinChance: " + str(
                                            winchance) + " Anonymous: " + str(
                                                anonymous
                                            ) + " username: "******" saving: " + str(
                                                    saving) + "\n"
                                try:
                                    ip = re.search(
                                        r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',
                                        username).group()
                                except AttributeError:
                                    pass
                                # print ip, type(ip), username, type(username)
                                s = requests.session()
                                if ip == username:
                                    print "send to database"
                                    print s.get(
                                        "https://vhack.olympiccode.ga/database/submit.php?IP="
                                        + str(ip) + "&MONEY=" + str(money) +
                                        "&IPSP=" + str(ipsplevel) + "&FW=" +
                                        str(fwlevel) + "&AV=" + str(avlevel))
                                    s.close()
                                else:
                                    print "send to database"
                                    print s.get(
                                        "https://vhack.olympiccode.ga/database/submit.php?IP="
                                        + str(ip) + "&USR="******"&MONEY=" + str(money) + "&IPSP=" +
                                        str(ipsplevel) + "&FW=" +
                                        str(fwlevel) + "&AV=" + str(avlevel))
                                    s.close()
                                return True
                            else:
                                print "\nYour Money: " + "{:11,}".format(
                                    int(jsons['newmoney'])
                                ) + "\n[TargetIP: " + str(
                                    ip) + "]\n\nMade " + "{:11,}".format(
                                        int(jsons['amount'])
                                    ) + " and " + "{:2d}".format(
                                        int(jsons['eloch'])
                                    ) + " Rep." + "\n Antivirus: " + str(
                                        avlevel) + " Firewall: " + str(
                                            fwlevel) + " Sdk: " + str(
                                                sdklevel
                                            ) + " TotalMoney: " + str(
                                                money
                                            ) + "\n YourWinChance: " + str(
                                                winchance
                                            ) + " Anonymous: " + str(
                                                anonymous
                                            ) + " username: "******" saving: " + str(
                                                    saving) + "\n"
                                try:
                                    ip = re.search(
                                        r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',
                                        username).group()
                                except AttributeError:
                                    pass
                                # print ip, type(ip), username, type(username)
                                s = requests.session()
                                if ip == username:
                                    print "send to database"
                                    s.get(
                                        "https://vhack.olympiccode.ga/database/submit.php?IP="
                                        + str(ip) + "&MONEY=" + str(money) +
                                        "&IPSP=" + str(ipsplevel) + "&FW=" +
                                        str(fwlevel) + "&AV=" + str(avlevel))
                                    s.close()
                                else:
                                    print "send to database"
                                    s.get(
                                        "https://vhack.olympiccode.ga/database/submit.php?IP="
                                        + str(ip) + "&USR="******"&MONEY=" + str(money) + "&IPSP=" +
                                        str(ipsplevel) + "&FW=" +
                                        str(fwlevel) + "&AV=" + str(avlevel))
                                    s.close()
                                return True

                        except KeyError:
                            print "Bad attack"
                            return False
                    else:
                        print "Password Incorrect"
                        return False
                else:
                    # print "\n"
                    if int(avlevel) > max:
                        print "Antivir to high " + str(avlevel)
                        # print "passed"
                        return False
                    if int(winchance) < 75:
                        print "winchance is poor: " + str(winchance)
                        # print "passed"
                        return False
                    if str(anonymous) == "NO":
                        print "Anonymous not needed"
                        # print "passed"
                        return False
            else:
                if len(avlevel) == 4:
                    print "Cant load User"
                    return False
                else:
                    print "Scan to low"
                    return False
        else:
            print "Password Error"
            return False
Exemple #11
0
import cv2
import numpy as np
from os import listdir
from os.path import isfile, join
from controls import Controls
from ocr import OCR
import time

#MAIN
ocrEngine = OCR("log/model.ckpt", "log/dict.pickle")
#get list of source images in images folder
imageList = [
    join("./images/", f) for f in listdir("./images/")
    if isfile(join("./images/", f)) and f[0] != '.' and f != 'test.jpeg'
]
if len(imageList) == 0:
    raise StandardError("No files in images/ directory")
#initialize window and control panel positions with stock trackbars
cv2.namedWindow('display', cv2.WINDOW_NORMAL)
controlsList = [(0, 150, 255), (0, 255, 255), (3, 5, 10),
                (0, 0, len(imageList) - 1)]
ctrl = Controls(controlsList)
cv2.resizeWindow('display', 800, 600)
cv2.moveWindow('display', 100, 0)
image = cv2.imread(imageList[ctrl.t[3]])
currentImageNo = ctrl.t[3]

#initialize variables
cv2.imshow('display', image)
while True:
    if currentImageNo != ctrl.t[3]:
Exemple #12
0
    def attackIP(self, ip, max):
        ut = Utils()
        info = self.myinfo()
        info = json.loads(info)
        uhash = info['uhash']
        temp = ut.requestString(
            "user::::pass::::uhash::::target",
            self.api.getUsername() + "::::" + self.api.getPassword() + "::::" +
            uhash + "::::" + ip, "vh_loadRemoteData.php")

        jsons = json.loads(temp)
        s = requests.Session()
        datasubmit = {
            'uName': 'username',
            'pWord': 'password',
        }
        r = s.post('https://www.echoofamarok.com/RedX/assets/php/login',
                   data=datasubmit)
        try:
            pat = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
            test = pat.match(jsons['username'])
            if test:
                try:
                    datasubmit = {
                        'nIP': jsons['ipaddress'],
                        'nName': '',
                        'nSpam': jsons['spam'],
                        'nIPSpoof': jsons['spam'],
                        'nFirewall': jsons['fw'],
                        'nAntivirus': jsons['av'],
                        'nSDK': jsons['sdk'],
                        'nSpyware': jsons['spyware'],
                        'nBalance': jsons['money'],
                        'nAddedBy': 'ULTIMATE'
                    }
                except TypeError:
                    print "DATA FALSE"
                    return False
            else:
                try:
                    datasubmit = {
                        'nIP': jsons['ipaddress'],
                        'nName': jsons['username'],
                        'nSpam': jsons['spam'],
                        'nIPSpoof': jsons['spam'],
                        'nFirewall': jsons['fw'],
                        'nAntivirus': jsons['av'],
                        'nSDK': jsons['sdk'],
                        'nSpyware': jsons['spyware'],
                        'nBalance': jsons['money'],
                        'nAddedBy': 'ULTIMATE'
                    }
                except TypeError:
                    print "DATA FALSE"
                    return False

        except TypeError:
            try:
                datasubmit = {
                    'nIP': jsons['ipaddress'],
                    'nName': '',
                    'nSpam': jsons['spam'],
                    'nIPSpoof': jsons['spam'],
                    'nFirewall': jsons['fw'],
                    'nAntivirus': jsons['av'],
                    'nSDK': jsons['sdk'],
                    'nSpyware': jsons['spyware'],
                    'nBalance': jsons['money'],
                    'nAddedBy': 'ULTIMATE'
                }
            except TypeError:
                print "DATA FALSE"
                return False

        r = s.post('https://www.echoofamarok.com/RedX/assets/php/AddEntry',
                   data=datasubmit)
        print "\nAdd to database " + str(jsons['ipaddress'])
        r.connection.close()

        o = OCR()
        imgs = o.getSolution(str(temp))
        if imgs != None:
            user = jsons['username']
            winchance = jsons['winchance']
            try:
                if not "?" in str(winchance):
                    fwlevel = jsons['fw']
                    avlevel = jsons['av']
                    spamlevel = jsons['spam']
                    sdklevel = jsons['sdk']
                    ipsplevel = jsons['sdk']
                    money = jsons['money']
                    saving = jsons['savings']
                    anonymous = jsons['anonymous']
                    username = jsons['username']
                    winlo = jsons['winelo']
                    winchance = jsons['winchance']
                    spywarelevel = jsons['spyware']
                else:
                    avlevel = "????"
                    winchance = 0
                    print "no scan username"
                    return False

            except TypeError:
                fwlevel = jsons['fw']
                avlevel = jsons['av']
                spamlevel = jsons['spam']
                sdklevel = jsons['sdk']
                ipsplevel = jsons['sdk']
                money = jsons['money']
                saving = jsons['savings']
                anonymous = jsons['anonymous']
                username = jsons['username']
                winlo = jsons['winelo']
                winchance = jsons['winchance']
                spywarelevel = jsons['spyware']

            if type(winchance) == "int":
                if "?" in winchance:
                    winchance = 0
                    print "no chance"
                    return False

            if not "?" in str(avlevel):
                if int(avlevel) < max and int(winchance) > 75 and str(
                        anonymous) == "YES":
                    password = self.enterPassword(imgs, ip, uhash)
                    jsons = json.loads(password)
                    if password:
                        try:
                            if not "?" in str(money) and str(
                                    jsons['result']) == 0:
                                print "\n[TargetIP: " + str(
                                    ip) + "]\n\nMade " + "{:11,}".format(
                                        int(jsons['amount'])
                                    ) + " and " + "{:2d}".format(
                                        int(jsons['eloch'])
                                    ) + " Rep." + "\n Antivirus: " + str(
                                        avlevel) + " Firewall: " + str(
                                            fwlevel
                                        ) + " Sdk: " + str(
                                            sdklevel
                                        ) + " TotalMoney: " + "{:11,}".format(
                                            int(money)
                                        ) + "\n YourWinChance: " + str(
                                            winchance) + " Anonymous: " + str(
                                                anonymous
                                            ) + " username: "******" saving: " + str(
                                                    saving)
                                return True
                            else:
                                print "\n[TargetIP: " + str(
                                    ip) + "]\n\nMade " + "{:11,}".format(
                                        int(jsons['amount'])
                                    ) + " and " + "{:2d}".format(
                                        int(jsons['eloch'])
                                    ) + " Rep." + "\n Antivirus: " + str(
                                        avlevel) + " Firewall: " + str(
                                            fwlevel
                                        ) + " Sdk: " + str(
                                            sdklevel
                                        ) + " TotalMoney: " + "{:11,}".format(
                                            int(money)
                                        ) + "\n YourWinChance: " + str(
                                            winchance) + " Anonymous: " + str(
                                                anonymous
                                            ) + " username: "******" saving: " + str(
                                                    saving)
                        except KeyError:
                            print "Bad attack"
                            return False
                    else:
                        print "Password Wrong"
                        return False
                else:
                    #print "\n"
                    if int(avlevel) > max:
                        print "Antivir to high " + str(avlevel)
                        #print "passed"
                        return False
                    if int(winchance) < 75:
                        print "winchance is poor: " + str(winchance)
                        #print "passed"
                        return False
                    if str(anonymous) == "NO":
                        print "No Anonymous need"
                        #print "passed"
                        return False
            else:
                print avlevel
                if len(avlevel) == 4:
                    print avlevel
                    print "Cant load User"
                    return False
                else:
                    print "Scan to low"
                    return False
        else:
            print "Password Error"
            return False
Exemple #13
0
    elif op == "txt_class_txt":
        startTime = time.time()
        for term in search_terms:
            c(files_path.docx, search=term)
            c(files_path.pptx, search=term)
            c(files_path.xlsx, search=term)
        #print("this functionality is not implemented yet")

    elif op == "txt_display":
        startTime = time.time()
        print("this functionality is not implemented yet")
        #TODO

    elif op == "img_class_txt":
        startTime = time.time()
        for term in search_terms:
            img2txt = OCR(files_path.img, lang="tur", search=term)
            pdf2txt = OCR(files_path.pdf,
                          lang="tur",
                          search=term,
                          file_type="pdf")

    elif op == "img_class_img":
        startTime = time.time()
        img_class_img(files_path.img, templates=templates.img)
        img_class_img(files_path.pdf, templates=templates.img, file_type="pdf")

    endTime = time.time()
    delta = int((endTime - startTime) * 1000)
    display_performance(delta)
test_cases = []
test_cases.append(('google.PNG', 'Google\n\n'))
test_cases.append(('python1.PNG', ''))


# Execute test cases.
print('\n')
for file_name, expected_text in test_cases:

    # Convert file to encoded Base64 string.
    file_path = test_files_path.format(file_name)
    with open(file_path, 'rb') as image_file:
        base_64_string = base64.b64encode(image_file.read())

        # Create OCR object.
        ocr = OCR(debug_mode=True)

        # Create temp_files directory.
        os.makedirs(ocr.temp_files_directory_path, exist_ok=True)

        # Get output.
        (recognized_text, _, _) = ocr.parse_image(base_64_string=base_64_string)

        # Delete temp_files directory.
        shutil.rmtree(ocr.temp_files_directory_path)

        # Case: test passed.
        if recognized_text == expected_text:
            print(test_passed.format(file_name))

        # Case: test failed.
Exemple #15
0
        # Assume all current candidates are equally likely
        s = sum(c[i - 1] for c in self.candidates)
        n = len(self.candidates)
        return int(round(float(s) / n))

    def __self__(self):
        return "<DeckReconstructor, n=%d, avgdeck={1:%d, 2:%d, 3:%d}>" % (len(
            self.candidates), self[1], self[2], self[3])

    def __repr__(self):
        return "<DeckReconstructor, candidates=%s>" % self.candidates


if __name__ == '__main__':
    # simple test sequence
    import sys, os
    dirname, startfn = sys.argv[1:]

    deck = None
    from ocr import OCR
    ocr = OCR("LGE Nexus 5")
    imglist = sorted([fn for fn in os.listdir(dirname) if fn >= startfn])
    for fn in imglist:
        print(fn)
        board, tileset = ocr.ocr(os.path.join(dirname, fn))
        if deck is None:
            deck = DeckReconstructor(board)
        deck.update(tileset[0])
        print(deck)
Exemple #16
0

@app.route("/detect", methods=["POST"])
def detect():
    image_path = request.json["image_path"]
    r = engine.detect_only(image_path)
    return jsonify(r)


@app.route("/recognize", methods=["GET"])
def recognize():
    r = engine.recognize_only()
    return jsonify(r)


if __name__ == "__main__":
    path_abs = os.path.dirname(os.path.abspath(__file__))
    opt = SimpleNamespace()
    opt.detect_trained_model = f"{path_abs}/models/craft_mlt_25k.pth"
    opt.detect_result_folder = f"{path_abs}/images/box/"
    opt.recognize_image_folder = f"{path_abs}/images/box/"
    opt.recognize_saved_model = f"{path_abs}/models/TPS-ResNet-BiLSTM-Attn.pth"
    opt.recognize_Transformation = "TPS"
    opt.recognize_FeatureExtraction = "ResNet"
    opt.recognize_SequenceModeling = "BiLSTM"
    opt.recognize_Prediction = "Attn"
    opt.test_image = f"{path_abs}/text_detect/images/example.jpg"
    engine = OCR(opt)
    app.run(host="localhost", port=8301, debug=True)

Exemple #17
0
    fourcc = cv.VideoWriter_fourcc(*"MJPG")
    out = cv.VideoWriter(args.out, fourcc, 20.0, (1920, 1080), True)

    yolo = Yolo(
        img_width=1056,
        img_height=576,
        confidence_threshold=0.6,
        non_max_supress_theshold=0.4,
        classes_filename='../config/classes.names',
        model_architecture_filename="../config/yolov3_license_plates.cfg",
        model_weights_filename="../config/yolov3_license_plates_last.weights",
        output_directory='../debug/',
        output_image=False)

    ocr = OCR(model_filename="../config/attention_ocr_model.pth",
              use_cuda=False,
              threshold=0.7)

    cap = cv.VideoCapture(args.input)

    while (cap.isOpened()):
        hasFrame, frame = cap.read()
        if hasFrame:
            roi_imgs = yolo.detect(frame)
            index = 0
            for roi_img in roi_imgs:
                box = [
                    yolo.bounding_boxes[index][0],
                    yolo.bounding_boxes[index][1],
                    yolo.bounding_boxes[index][2],
                    yolo.bounding_boxes[index][3]
Exemple #18
0
from files import ImageFile
from segmentation import ContourSegmenter, draw_segments
from feature_extraction import SimpleFeatureExtractor
from classification import KNNClassifier
from ocr import OCR, accuracy, show_differences, reconstruct_chars

segmenter = ContourSegmenter(blur_y=5, blur_x=5, block_size=11, c=10)
extractor = SimpleFeatureExtractor(feature_size=10, stretch=False)
classifier = KNNClassifier()
ocr = OCR(segmenter, extractor, classifier)

ocr.train(ImageFile('digits1'), ImageFile('alpha'))

test_image = ImageFile('alpha')
test_classes, test_segments = ocr.ocr(test_image, show_steps=True)

print "accuracy:", accuracy(test_image.ground.classes, test_classes)
print "OCRed text:\n", reconstruct_chars(test_classes)
show_differences(test_image.image, test_segments, test_image.ground.classes,
                 test_classes)
Exemple #19
0
# -*- coding:utf-8 -*-
import json
import base64
import falcon
from img_log import api
import cv2
import numpy as np

from ocr import OCR
text_rec = OCR()


class Validate(object):
    def on_get(self, req, resp):
        resp.status = falcon.HTTP_200
        resp.body = 'Service started!'


class ForwardImg(object):
    def on_post(self, req, resp):
        res = None
        img = ''
        # Data comes from business.
        while True:
            chunk = req.stream.read(4096)
            if not chunk:
                break
            img += chunk

    # img = req.stream.read()
    # content length 校验