(Context context)
| 149 | private final static LinkedList<SettingReceiver> mSettingReceivers = new LinkedList<SettingReceiver>(); |
| 150 | |
| 151 | public static void init(Context context) throws Exception{ |
| 152 | mContext = context; |
| 153 | try{ |
| 154 | Logger.debug("initializing System..."); |
| 155 | mStoragePath = getSettings().getString("PREF_SAVE_PATH", Environment.getExternalStorageDirectory().toString()); |
| 156 | mSessionName = "csploit-session-" + java.lang.System.currentTimeMillis(); |
| 157 | mKnownIssues = new KnownIssues(); |
| 158 | mPlugins = new ArrayList<>(); |
| 159 | mOpenPorts = new SparseIntArray(3); |
| 160 | mServices = new HashMap<>(); |
| 161 | mPorts = new HashMap<>(); |
| 162 | |
| 163 | // if we are here, network initialization didn't throw any error, lock wifi |
| 164 | WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); |
| 165 | |
| 166 | if(mWifiLock == null) |
| 167 | mWifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, "wifiLock"); |
| 168 | |
| 169 | if(!mWifiLock.isHeld()) |
| 170 | mWifiLock.acquire(); |
| 171 | |
| 172 | // wake lock if enabled |
| 173 | if(getSettings().getBoolean("PREF_WAKE_LOCK", true)){ |
| 174 | PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
| 175 | |
| 176 | if(mWakeLock == null) |
| 177 | mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "wakeLock"); |
| 178 | |
| 179 | if(!mWakeLock.isHeld()) |
| 180 | mWakeLock.acquire(); |
| 181 | } |
| 182 | |
| 183 | // set ports |
| 184 | try{ |
| 185 | HTTP_PROXY_PORT = Integer.parseInt(getSettings().getString("PREF_HTTP_PROXY_PORT", "8080")); |
| 186 | HTTP_SERVER_PORT = Integer.parseInt(getSettings().getString("PREF_HTTP_SERVER_PORT", "8081")); |
| 187 | HTTPS_REDIR_PORT = Integer.parseInt(getSettings().getString("PREF_HTTPS_REDIRECTOR_PORT", "8082")); |
| 188 | MSF_RPC_PORT = Integer.parseInt(getSettings().getString("MSF_RPC_PORT", "55553")); |
| 189 | } catch(NumberFormatException e){ |
| 190 | HTTP_PROXY_PORT = 8080; |
| 191 | HTTP_SERVER_PORT = 8081; |
| 192 | HTTPS_REDIR_PORT = 8082; |
| 193 | MSF_RPC_PORT = 55553; |
| 194 | } |
| 195 | |
| 196 | uncaughtReloadNetworkMapping(); |
| 197 | |
| 198 | ThreadHelper.getSharedExecutor().execute(new Runnable() { |
| 199 | @Override |
| 200 | public void run() { |
| 201 | preloadServices(); |
| 202 | preloadVendors(); |
| 203 | } |
| 204 | }); |
| 205 | } |
| 206 | catch(Exception e){ |
| 207 | if(!(e instanceof NoRouteToHostException)) |
| 208 | errorLogging(e); |
no test coverage detected