From bbc45b7a3982e43871350df5cd28bd8758382642 Mon Sep 17 00:00:00 2001 From: woo Date: Mon, 3 Jul 2023 11:13:43 +0900 Subject: [PATCH] =?UTF-8?q?IPIgnore=20Interceptor=20=ED=97=A4=EB=8D=94=20?= =?UTF-8?q?=EC=95=84=EC=9D=B4=ED=94=BC=20=EC=A1=B0=EC=9E=91=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20=EC=95=84=EC=9D=B4=ED=94=BC=20=ED=8C=A8?= =?UTF-8?q?=ED=84=B4=20=EA=B2=80=EC=82=AC=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=20=20-=20=EC=95=84=EC=9D=B4=ED=94=BC=20=EA=B2=80?= =?UTF-8?q?=EC=82=AC=20=EC=8B=A4=ED=8C=A8(=EC=98=A4=EB=A5=98)=20=EB=B0=9C?= =?UTF-8?q?=EC=83=9D=20=ED=98=B9=EC=9D=80=20=EC=95=84=EC=9D=B4=ED=94=BC=20?= =?UTF-8?q?=EB=B2=94=EC=9C=84=EA=B0=80=20=EC=95=84=EB=8B=8C=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EC=98=A4=EB=A5=98=20=EB=B0=9C=EC=83=9D=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IPIgnoreInterceptorHandler.java | 56 +++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/src/main/java/itn/com/cmm/interceptor/IPIgnoreInterceptorHandler.java b/src/main/java/itn/com/cmm/interceptor/IPIgnoreInterceptorHandler.java index 8a0a4742..8704736f 100644 --- a/src/main/java/itn/com/cmm/interceptor/IPIgnoreInterceptorHandler.java +++ b/src/main/java/itn/com/cmm/interceptor/IPIgnoreInterceptorHandler.java @@ -84,6 +84,48 @@ public class IPIgnoreInterceptorHandler extends HandlerInterceptorAdapter{ HackIpVO hackIpVO = new HackIpVO(); hackIpVO.setIgnoreIp(userIP); + + /* + * 헤더 아이피 체크 해주기 + * "." 기준으로 문자열 분할 후 0 ~ 255 사이 값인지 체크 + * 범위 값이 아닌경우 오류 처리 + * + * */ + String[] checkIP = userIP.split("\\."); + boolean ipCheckType = false; + + if(checkIP.length < 4 || checkIP == null) { + + System.out.println("IPIgnoreInterceptorHandler-preHandle Header IP Check ERROR !!! "); + System.out.println("userIP ::: "+userIP); + response.sendRedirect(request.getContextPath() + "/"); + return true; + + }else { + + for(String tmp : checkIP) { + + int ipNum = Integer.parseInt(tmp); + + if(ipNum >=0 && ipNum <= 255) { + + ipCheckType = true; + + } + + } + + } + + + if(!ipCheckType) { + + System.out.println("IPIgnoreInterceptorHandler-preHandle Header IP Check ERROR !!! "); + System.out.println("userIP ::: "+userIP); + response.sendRedirect(request.getContextPath() + "/"); + return true; + + } int i_ignoreCnt = hackIpService.selectIgnoreIpCnt(hackIpVO); @@ -151,7 +193,11 @@ public class IPIgnoreInterceptorHandler extends HandlerInterceptorAdapter{ loginLogService.logInsertLoginLog4Ajax(loginLog); }catch(Exception ex) { - ex.printStackTrace(); + //ex.printStackTrace(); + System.out.println("IPIgnoreInterceptorHandler-preHandle Error !!! " + ex); + //오류가 발생하면 메일화면으로 이동 시킨다. + response.sendRedirect(request.getContextPath() + "/"); + return true; } } @@ -163,11 +209,13 @@ public class IPIgnoreInterceptorHandler extends HandlerInterceptorAdapter{ }catch(Exception ex) { - ex.printStackTrace(); + //ex.printStackTrace(); + System.out.println("IPIgnoreInterceptorHandler-preHandle Error !!! " + ex); + //오류가 발생하면 경로 오류를 발생 시킨다. + response.sendRedirect(request.getContextPath() + "/"); + return true; } - - return v_ret; }