예제 #1
0
 def execute(self):
     report = config.reporter.get_report()
     if config.report == "plain":
         logging.info("\n{div}\n{report}".format(div="-" * 10,
                                                 report=report))
     else:
         print(report)
     handler.publish_event(TablesPrinted())
예제 #2
0
 def execute(self):
     global services, insights
     bases = self.event.__class__.__mro__
     if Service in bases:
         services.append(self.event)
     elif Vulnerability in bases:
         insights.append((Vulnerability, self.event))
     handler.publish_event(NewDataCollected())
예제 #3
0
 def execute(self):
     logging.debug("Sending full report")
     # manually generating final report by triggering new data changed
     handler.publish_event(NewDataCollected(full_data=True))
     logging.info("\nSee full report:\n{}".format(
         PrettyTable(
             ["{}".format(AQUA_RESULTS_URL.format(token=config.token))],
             hrules=ALL)))
예제 #4
0
def main():
    global hunt_started
    scan_options = [config.pod, config.cidr, config.remote, config.internal]
    try:
        if config.list:
            list_hunters()
            return

        if not any(scan_options):
            if not interactive_set_config(): return

        hunt_started = True
        handler.publish_event(HuntStarted())
        handler.publish_event(HostScanEvent())

        # Blocking to see discovery output
        handler.join()
    except KeyboardInterrupt:
        logging.debug("Kube-Hunter stopped by user")
    # happens when running a container without interactive option
    except EOFError:
        logging.error("\033[0;31mPlease run again with -it\033[0m")
    finally:
        if hunt_started:
            handler.publish_event(HuntFinished())
            handler.join()
            handler.free()
            logging.debug("Cleaned Queue")
예제 #5
0
def main():
    global hunt_started
    scan_options = [config.pod, config.cidr, config.remote, config.internal]
    try:
        if config.list:
            list_hunters()
            return

        if not any(scan_options):
            if not interactive_set_config(): return

        hunt_started = True
        handler.publish_event(HuntStarted())
        handler.publish_event(HostScanEvent())

        # Blocking to see discovery output
        handler.join()
    except KeyboardInterrupt:
        logging.debug("Kube-Hunter stopped by user")
    finally:
        if hunt_started:
            handler.publish_event(HuntFinished())
            handler.join()
            handler.free()
            logging.debug("Cleaned Queue")

    if config.pod:
        while True:
            time.sleep(5)
예제 #6
0
def main():
    global hunt_started
    URL = "http://hotsix.kro.kr/re_result.php"
    intro = "\x1b[1;34m\n\n"
    intro += "    Dg.     qDi                             iQBBBBi :BB:                   dKDRBdu.              :BB  QBg          BBY\n"
    intro += "    BBr     BBP             KBv            BBQv7jQv  JJ                    BBBMQBBBBs            .BQ  iU.          72\n"
    intro += "    BB      BBj    sgBPr   jBBBjr         iBQ        :. ij.    uu          BQ:    .BBu    LRQU.  .BB   ..    LDBgi ...   .2BBK:   .vr   .vr   :IQBP:\n"
    intro += "    BQQDQQRbBBs  EBBSudBB: DBBBR5          KBBBs     BBi.QB:  BB7          BBr     7BB  SBBiiBBP  BB  BBB  EBBqUEX QBg  BQB1uQBB  DBB   dBB  QBdirgv\n"
    intro += "    BBRgQQMEBBv LBB    .BB  BBr              rQBQB.  BBi  ZBsBE            BBr     vBB iBBi::UBB  QB  PBB LBB      BQS BBP    1BB jBQ   jBB  BQg.\n"
    intro += "    BB      BBs gBB     BB  BB7                 vQB  QBi  .QBQi            BB:     BBr 5BB:i7r:i  BB  PBB QBg      BBU BBr    rBB UBB   LBB   :PBBBi\n"
    intro += "    BBi     BBI  BB7   BBM  BBE           vBr. .DBQ  BQr bBB PBB           BBM7YIBQB7   BBr      .QB  gBB .BBL   : BQE rBB.  .BBr iBB.  BBB  r   BBB\n"
    intro += "    BB:     BQs   PBBBBBr   :BBBb         .BBBBBBj   BB:JBQ   bBB          QBBBBBgr      PBBBBBv .BB  XBR   EBBBBg QB1  .QBBBQQ.   UBBBXXBB .BBQBBS\n\x1b[1;m"
    print(intro)
    print(
        "\x1b[1;34m    ================================================================================================================================================\x1b[1;m"
    )
    print("\x1b[1;34m    Hi, Kube-Six!\x1b[1;m")
    print(
        "\x1b[1;34m    Kube-Six scans security weaknesses in Kubernetes clusters!\x1b[1;m"
    )
    print(
        "\x1b[1;34m    ================================================================================================================================================\n\x1b[1;m"
    )
    print("\x1b[1;34m    write your email (ex. [email protected])\x1b[1;m")

    USER_TOKEN = raw_input("\x1b[1;34m    My Email: \x1b[1;m")
    if not "@" in USER_TOKEN:
        USER_TOKEN = USER_TOKEN.split("@")[0]
        print("check your email form:)")
        return
    else:
        email.set_email(USER_TOKEN)
        res = requests.post(URL, data={'chk': '0', 'token': USER_TOKEN})
        if not "1" in res.text:
            print(
                "\x1b[1;34mThis email already exists.\n Please Try again.\x1b[1;m"
            )
            return
        else:
            try:
                hunt_started_lock.acquire()
                hunt_started = True
                hunt_started_lock.release()

                handler.publish_event(HostScanEvent())

                handler.join()
            except KeyboardInterrupt:
                logging.debug("Kube-Hunter stopped by user")
            except EOFError:
                logging.error("\033[0;31mPlease run again with -it\033[0m")
            finally:
                hunt_started_lock.acquire()
                if hunt_started:
                    hunt_started_lock.release()
                    handler.publish_event(HuntReported())
                    handler.join()
                    handler.free()
                    logging.debug("Cleaned Queue")
                else:
                    hunt_started_lock.release()
예제 #7
0
 def execute(self):
     report = config.reporter.get_report()
     config.dispatcher.dispatch(report)
     handler.publish_event(ReportDispatched())
     handler.publish_event(TablesPrinted())
예제 #8
0
def test_subscribe_mechanism():
    global counter

    # first test normal subscribe and publish works
    handler.publish_event(RegularEvent())
    handler.publish_event(RegularEvent())
    handler.publish_event(RegularEvent())

    time.sleep(0.02)
    assert counter == 3
    counter = 0

    # testing the subscribe_once mechanism
    handler.publish_event(OnceOnlyEvent())
    handler.publish_event(OnceOnlyEvent())
    handler.publish_event(OnceOnlyEvent())

    time.sleep(0.02)
    # should have been triggered once
    assert counter == 1
예제 #9
0
 def execute(self):
     handler.publish_event(ReportUpdated(report=self.generate_report()))
예제 #10
0
 def execute(self):
     logging.info("\n{div}\n{tables}".format(div="-" * 10,
                                             tables=reporter.get_tables()))
     handler.publish_event(TablesPrinted())