mac 에서 npm install -g 시 오류 "no such file or directory, chmod"

Study-programing/linux-server|2016. 12. 8. 17:24

리눅스는 아니지만, UNIX like 는 한 가족 입니다.


이번에, 외주 작업 중, mac book pro 를 사용하게 되어 고생중 인데...

`npm install -g' 이 죽어도 안됩니다.


오류 메시지가 제목에도 있는


no such file or directory, chmod ...



였는데요.


구글링 중 원인을 찾았습니다.

바로, mac이 chmod 같은 위험한 명령어를 막더라구요.

(ㅂㄷㅂㄷ)


--unsafe-perm=true


위, 옵션을 주고 설치하니 성공했습니다.




이 글을 읽고 성공하시는 분들은 6시간을 아끼시는겁니다.

제가 저게 원인임을 찾기까지, 6시간 걸렸거든요.


댓글()

Hack The Packet 2014 Write up

Study-security/Let's CTF|2016. 11. 8. 21:44

동아리 홈피에 예전에 작성한 글 이다.

요즘은 Hack the packet 안하나요...?


Hack the packet 2014 online qual


Low

L1 : Alies leave a Secret Message using SMB for assistant bob.

smb 프로토콜을 사용하여 전송하였으므로, wireshark 로 smb protocol 로 전송한 데이터를 모두 뽑아내 보았으나, fail.. 포기하였다.

L2 : NFS server got compromised, Find out name of hacker"s public key!

wireshack 를 통해 NFS 로 filtering 을 하였다.

K_EY_H@CK.pub 라는 퍼블릭 키를 발견 할 수 있었다.

L3 : What is a model of cell phone which is installed malicious application?

주어진 패킷에 핸드폰 기종이 나오는 위치는 User-Agent 이외엔 없으리라 추측. 리눅스에서

grep "User-Agent" -an ./prob.pcap > test

명령어를 이용하여, User-Agent 값을 추출하였다.

SHV-E210S 라는 기종명을 찾을 수 있었다.

Medium

M1 : Find what is the field name of the fourth was investigated attacker through the attack of SQL Injection

having 절을 통해 sql injection 공격을 하였으므로, having 을 검색하였다.

검색을 통해 나온 구문은, 모든 컬럼을 얻기 위하여 시도를 하는 내용이었다.

이 중, 4번째로 획득한 컬럼인, bbs.tMail 이 답이 된다.

M2 : ggobi edited photos using the usb .(10/09 21 hour after) ggobi remembered that brother is in house that day. USB product name of brother ?

참고 사이트

USB를 PC에 연결할 경우, Windows는 장치 드라이버를 검색한다.

따라서, 장치 드라이버를 검색하는 패킷을 찾기로 하였다.

grep "uPnP" -an ./prob.pcap > test2

여기서, 의심스러운 항목을 찾아보려 했지만, 너무 광범위 하였다.

따라서 검색을 통해 "USBSTOR" 이란 키워드를 찾아낼 수 있었다.

찾아낸 구문중, 21시 이후의 내용은

Disk&Ven_{Vendor Name}&Prod_{Product Name}&Rev_{Version}

위와 같은 포맷으로 이루어져 있으며 아래와 같다.

USBSTOR#DISK&VEN_SANDISK&PROD_CRUZER_BLADE&REV_1.26

따라서, PROD_CRUZER_BLADE 가 답이다.

M4 : Garumi logged on cloud as Rul’s ID and downloaded something. After downloading, she realized that her computer is infected with a virus.

이 문제의 힌트는 zip file 이다.

pcap 파일을 vim 으로 연 다음. :/.zip 명령어를 통해 zip 파일을 찾아보았다.

Adobe Photoshop CS2_kor.zip

란 이름의 파일 하나만 발견되었다.

패킷이 쪼개져서 전송되므로, TCP stream 을 통해 패킷을 이은 다음 저장을 한 후,

PK 매직넘버 앞의 값을 지워서 올바른 zip 포맷으로 바꾼 후 앞축을 풀면

Adobe Photoshop CS2.exe

란 이름의 파일을 얻을 수 있다.

HIGH

H1 : Yongja is very lazy, but like CTF. So, he decided to use BF to solve BOF chall. Some hours later, he got shell from chall server (bindshell). But he did mistake, lost the shell connection! He can’t do BF anymore(was warned by OP). Find correct return address in the exploit packet!

BF 시도 결과가 너무 많아서 탐색 실패.

H2 : Yongja’s website that based on Apache Struts got melong! Please let us know what is the CVE(used vuln) and where is the site to change bad guy want?

exploit db 에서 apache struts 로 검색하니 몇가지 cve가 나왔다.

이 중 가장 위의 CVE의 POC를 확인 한 결과, .../action?Class.classLoader......

의 형태로 만들어져 있으므로, pcap 파일에서 grap 으로 해당 문구가 있는 줄을 긁어냈다.

GET /struts2-blank/example/HelloWorld.action?Class.classLoader.reurces.dirContext.docBase=aHR0cDovL3d3dy5oYWNrdGhlcGFja2V0LmNvbS9Lb3JlYW5fVGhhbmtzZ2l2aW5nX0RheS8oXk9eKS8oXk9eKS8v

위와 같은 GET 요청을 발견 할 수 있었다.

docBase 는 문서의 주소 이므로, 뒤 문구를 복호화 해야 한다.

Base64 처럼 생겨서, Base64로 디코딩 해보니

http://www.hackthepacket.com/Korean_Thanksgiving_Day/(^O^)/(^O^)//

라는 주소를 얻을 수 있었다.

H3 : YongGAL who was infected by Malware, asked for help from padran, an analytical expert. Search for the name of the infected Malware

힌트인 iframe 으로 전체 파일을 검색하다 보면, comment 데이터에 iframe 태그를 삽입한 흔적을 발견할 수 있다.

해당 패킷으로 TCP stream 하면, User id 인 "GALIGALI" 와 삽입된 주소인 "http://h_@ckGALI.H^T^P.com"

을 확인 가능하다.

댓글()

Code Like Pythonist PPT

Study-programing/Python|2016. 11. 4. 20:13


본래 http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html  에 있는 내용이다.

문서 읽고 참 좋은 내용이다 싶어서, 진행하고 있는 스터디와, 듣고 있는 수업 발표로 공유하려고 PPT로 만들었다.


보기 좋은 떡이 먹기도 좋다니까.ㅎ


PPT는 나름 요약해 놔서, 보시구 이해 안가시면 원본 문서를 보시는 것도 좋겠다.

나름, 다 이해했다고 생각하니, 댓글로 물어보셔도 좋구.

'Study-programing > Python' 카테고리의 다른 글

Windows 에서 pip가 안돼요 ㅜㅜ 해결법  (0) 2018.05.01
windows pip install 문제 해결  (0) 2016.09.20

댓글()

windows pip install 문제 해결

Study-programing/Python|2016. 9. 20. 15:34

windows 환경에서 python 을 쓰다 보니,

요상한 에러가 괴롭히는 문제가 발생했습니다... 


"UnicodeDecoderError: 'ascii' codec can't decode byte 0xc0 in position 0: ...."


분석해본 결과 원인은 cp949...

이놈의 python은 한글이 매번 골치네요...


문제가 되는 부분을 수정해서 해결하였습니다.


문제가 되는 코드는 "C:\python27\Lib\ntpath.py" 에 있는 join 이란 함수 입니다.

(2.7.12 기준 85번째 라인)




# Join two (or more) paths.
def join(path, *paths):
    """Join two or more pathname components, inserting "\\" as needed."""
    result_drive, result_path = splitdrive(path)
    for p in paths:
        p_drive, p_path = splitdrive(p)
        if p_path and p_path[0] in '\\/':
            # Second path is absolute
            if p_drive or not result_drive:
                result_drive = p_drive
            result_path = p_path
            continue
        elif p_drive and p_drive != result_drive:
            if p_drive.lower() != result_drive.lower():
                # Different drives => ignore the first path entirely
                result_drive = p_drive
                result_path = p_path
                continue
            # Same drive in different case
            result_drive = p_drive
        # Second path is relative to the first
        if result_path and result_path[-1] not in '\\/':
            result_path = result_path + '\\'
        result_path = result_path + p_path
    ## add separator between UNC and non-absolute path
    if (result_path and result_path[0] not in '\\/' and
        result_drive and result_drive[-1:] != ':'):
        return result_drive + sep + result_path
    return result_drive + result_path

붉게 표시한 두 부분이 문제가 되는데요,

아래와 같이 수정하여 해결 가능합니다.

(전체를 붙여넣기로 수정하셔도 됩니다.)




# Join two (or more) paths.
def join(path, *paths):
    """Join two or more pathname components, inserting "\\" as needed."""
    result_drive, result_path = splitdrive(path)
    for p in paths:
        p_drive, p_path = splitdrive(p)
        if p_path and p_path[0] in '\\/':
            # Second path is absolute
            if p_drive or not result_drive:
                result_drive = p_drive
            result_path = p_path
            continue
        elif p_drive and p_drive != result_drive:
            if p_drive.lower() != result_drive.lower():
                # Different drives => ignore the first path entirely
                result_drive = p_drive
                result_path = p_path
                continue
            # Same drive in different case
            result_drive = p_drive
        # Second path is relative to the first
        if result_path and result_path[-1] not in '\\/':
            result_path = result_path + '\\'
        result_path = result_path + p_path.decode("cp949")
    ## add separator between UNC and non-absolute path
    if (result_path and result_path[0] not in '\\/' and
        result_drive and result_drive[-1:] != ':'):
        return result_drive + sep + result_path
    return (result_drive + result_path).encode("utf-8")



#2016.10.10  위 내용은 PC의 이름이 한글이 때 해결 방법 이다. Username 이 한글일 때는 위 방법으로 해결되지 않는다. 

'Study-programing > Python' 카테고리의 다른 글

Windows 에서 pip가 안돼요 ㅜㅜ 해결법  (0) 2018.05.01
Code Like Pythonist PPT  (0) 2016.11.04

댓글()