keyword:web滲透檢測,安全檢測,AppScan
web滲透檢測 滲透的本質是漏洞。web滲透檢測也即web漏洞檢測。
AppScan安全掃描報告
如下是問題類型為“已解密的登陸請求”中提到的問題-詳情
改造方案:
服務端添加獲取加密秘鑰的接口:/getLoginSignKey。
前端在調用登陸接口時,先調用 /getLoginSignKey 接口,獲取加密key,對用戶登陸密碼進行加密。然后,調用登陸接口時,上送加密后的用戶密碼參數。
服務端登陸接口在獲取到登陸請求參數時,先對密碼做解密,再執行原有驗證邏輯。
改造代碼:
/getLoginSignKey 接口
private static final String LOGIN_SIGN_KEY_CACHE = "loginSignKeyCache:"; // 獲取登錄簽名key @RequestMapping(value = "/getLoginSignKey", method = RequestMethod.POST) public Result<String> getLoginSignKey(@RequestBody SysLoginModel sysLoginModel) throws Exception { String cacheKey = LOGIN_SIGN_KEY_CACHE + sysLoginModel.getUsername(); Object signCache = redisUtil.get(cacheKey); if (ObjectUtil.isNotNull(signCache)) { return Result.successWithMsg(signCache.toString()); } KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA"); // 初始化密鑰對生成器,密鑰大小為96-1024位 keyPairGen.initialize(1024, new SecureRandom()); // 生成一個密鑰對,保存在keyPair中 KeyPair keyPair = keyPairGen.generateKeyPair(); // 得到公鑰字符串 String publicKeyString = com.emax.zhenghe.common.util.Base64.encode(keyPair.getPublic().getEncoded()); // 得到私鑰字符串 String privateKeyString = Base64.encode(keyPair.getPrivate().getEncoded()); redisUtil.set(cacheKey, privateKeyString, 7 * 24 * 60 * 60); //7天有效 return Result.successWithMsg(publicKeyString); }
登陸接口改造
// 登錄接口 @RequestMapping(value = "/login", method = RequestMethod.POST) public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel) { Result<JSONObject> result = new Result<JSONObject>(); String username = sysLoginModel.getUsername(); String password = ""; log.info("用戶登陸--系統登錄--/sys/login--username={}", username); // 設置登錄次數限制 Result loginLimitResult = loginLimitValidate(sysLoginModel.getUsername()); if (!loginLimitResult.isSuccess()) return loginLimitResult; //密碼加密驗簽: String signCacheKey = LOGIN_SIGN_KEY_CACHE + sysLoginModel.getUsername(); Object signPrivateKeyCache = redisUtil.get(signCacheKey); if (ObjectUtil.isNull(signPrivateKeyCache)) { result.error500("非法請求!"); return result; } try { password = new String(RSAUtils.decryptByPrivateKey(Base64.decode(sysLoginModel.getPassword()), signPrivateKeyCache.toString())); } catch (Exception e) { log.info("login--username={},解密失敗", sysLoginModel.getUsername()); result.error500("非法請求!"); return result; } ..... 原有登陸邏輯 }
前端頁面請求的網絡調用:
根據登陸用戶去拿key
調用登陸接口,密碼是加密后的密文