위는 natas23의 초기화면이다.

 

아래 코드는 View sourcecode를 통해 확인해주었다.

<html>
<head>
<!-- This stuff in the header has nothing to do with the level -->
<link rel="stylesheet" type="text/css" href="http://natas.labs.overthewire.org/css/level.css">
<link rel="stylesheet" href="http://natas.labs.overthewire.org/css/jquery-ui.css" />
<link rel="stylesheet" href="http://natas.labs.overthewire.org/css/wechall.css" />
<script src="http://natas.labs.overthewire.org/js/jquery-1.9.1.js"></script>
<script src="http://natas.labs.overthewire.org/js/jquery-ui.js"></script>
<script src="http://natas.labs.overthewire.org/js/wechall-data.js"></script><script src="http://natas.labs.overthewire.org/js/wechall.js"></script>
<script>var wechallinfo = { "level": "natas23", "pass": "<censored>" };</script></head>
<body>
<h1>natas23</h1>
<div id="content">

Password:
<form name="input" method="get">
    <input type="text" name="passwd" size=20>
    <input type="submit" value="Login">
</form>

<?php
    if(array_key_exists("passwd",$_REQUEST)){
        if(strstr($_REQUEST["passwd"],"iloveyou") && ($_REQUEST["passwd"] > 10 )){
            echo "<br>The credentials for the next level are:<br>";
            echo "<pre>Username: natas24 Password: <censored></pre>";
        }
        else{
            echo "<br>Wrong!<br>";
        }
    }
    // morla / 10111
?>  
<div id="viewsource"><a href="index-source.html">View sourcecode</a></div>
</div>
</body>
</html>

passwd에 iloveyou라는 문자열이 포함되어 있으며, 10보다 크면 비밀번호를 획득할 수 있다.

 

아무 입력 없이 Login 을 눌러주었더니 Wrong! 이라는 문구가 떴다.

 

10보다 커야하기 때문에 10보다 큰 수인 11을 앞에 넣어주고 그 후에 iloveyou 문자열을 붙여주었다.

입력 : 11iloveyou

이를 통해 비밀번호를 구할 수 있었다.

|0xzF30T9Av8lgXhW7slhFCIsVKAPyl2r

'Web Hacking > Natas' 카테고리의 다른 글

[Natas] Level 23 > Level 24  (0) 2022.11.19
[Natas] Level 21 > Level 22  (0) 2022.11.05
[Natas] Level 20 > Level 21  (0) 2022.10.09
[Natas] Level 19 > Level 20  (0) 2022.10.02
[Natas] Level 18 > Level 19  (0) 2022.09.24

n, m=map(int, input().split())
d=dict()
ans=0
for i in range(n):
    str1=input()
    d[str1]=1
for i in range(m):
    str2=input()
    if str2 in d:
        ans += 1
print(ans)

<코드 설명>

문자열 개수인 n과 m을 입력받아주었다.

n만큼 str1을 input받아 dict에 str1을 각각 1의 값을 저장해주었다.

m만큼 str2를 input받았다.

이전 dict에 저장해주었던 값에 str2가 포함되어 있다면 ans를 1 증가해주었다.

이렇게 구한 ans값을 출력해주었다.

 

<실행 결과>

'Algorithm > BOJ' 카테고리의 다른 글

[BOJ] 3077 임진왜란  (0) 2022.11.13
[BOJ] 4889 안정적인 문자열  (0) 2022.11.13
[BOJ] 16499 동일한 단어 그룹화하기  (0) 2022.11.06
[BOJ] 13417 카드 문자열  (0) 2022.11.06
[BOJ] 1065 한수  (0) 2022.10.09

tc=int(input())
arr=[]
for i in range(tc):
    str=list(input())
    str=sorted(str)
    if str not in arr:
        arr.append(str)
print(len(arr))

<코드 설명>

먼저 testcase인 tc를 입력받아주었다.

tc만큼 for문을 통해 반복하여 단어(str)을 입력받았다.

그리고 이를 sorted 적용을 통해 정렬해주었다.

arr가 str에 포함되어 있지 않다면, arr에 str을 추가해주었다.

그리고 최종적으로 arr에 저장되어 있는 개수를 출력하여 그룹의 최소 개수를 출력해주었다.

 

 

<실행 결과>

'Algorithm > BOJ' 카테고리의 다른 글

[BOJ] 4889 안정적인 문자열  (0) 2022.11.13
[BOJ] 14425 문자열 집합  (0) 2022.11.06
[BOJ] 13417 카드 문자열  (0) 2022.11.06
[BOJ] 1065 한수  (0) 2022.10.09
[BOJ] 2776 암기왕  (0) 2022.10.09

 

tc=int(input())
for i in range(tc):
    n=int(input())
    str=list(input().split())
    arr=[str[0]]

    for j in range(1, len(str)):
        left = arr[0]
        if str[j] <= left:
            arr.insert(0,str[j])
        else:
            arr.append(str[j])
    for j in arr:
        print(j, end='')
    print()

<코드 설명>

먼저 testcase를 입력받는다. 그리고 그만큼 for문을 반복시켜 각 카드의 개수와 카드에 적힌 알파벳을 입력받는다.

입력받아온 알파벳은 split하여 str에 list의 형태로 적용해주었다.

arr 배열을 만들어 str의 첫번째 값을 저장해주었다.

arr의 첫번째 원소가 str[j]원소보다 크거나 같을 때, arr배열의 첫번째 원소로 str[j] 원소를 삽입해준다.

그렇지 않다면, arr배열 맨 뒤에 str[j]원소를 삽입해준다.

이를 str list의 길이만큼 반복시켜주었다.

이렇게 구한 arr배열의 원소를 출력시켜주었다.

 

 

<실행 결과>

'Algorithm > BOJ' 카테고리의 다른 글

[BOJ] 14425 문자열 집합  (0) 2022.11.06
[BOJ] 16499 동일한 단어 그룹화하기  (0) 2022.11.06
[BOJ] 1065 한수  (0) 2022.10.09
[BOJ] 2776 암기왕  (0) 2022.10.09
[BOJ] 9322 철벽 보안 알고리즘  (0) 2022.10.09

+ Recent posts