본문 바로가기

컴퓨터

buffer overflow 코딩 #include void main(){char *name;char *command;name=(char *)malloc(10);command=(char *)malloc(128);printf("address of Name is : %d \n", name);printf("address of Command is : %d \n", command);printf("Difference between address is : %d \n", command-name);printf("hey Enter your name: ");gets(name);printf("Hellow %s\n", name);system(command); } 컴파일MacBook-2:~ MGP$ gcc buffer.c -o buffer 실행MacBook-.. 더보기
Eclipse와 APM 연동하기 APM_SetUP 설치 http://www.apmsetup.com/ Eclipse 설치 http://www.eclipse.org/ PDT 설치 Help - Install New Software... 클릭 Juno - http://download.eclipse.org/releases/juno 접속 Programming Languages -> PHP Development Tools (PDT) SDK Feature 체크 후 설치 설치 완료 후 재시작 Eclipse 와 APM 연동 Windows->Preferences->PHP->PHP Executables 에서 Add 클릭 APM 설치경로 변경이 없을 경우 Name: 아무거나 Executable path: C:\APM_Setup\Server\PHP5\php.e.. 더보기
카카오톡 더보기
JSON JSON(제이슨, JavaScript Object Notation)은 인터넷에서 자료를 주고받을 때 그 자료를 표현하는 방법이다.그 형식은 자바스크립트의 구문 형식을 따르지만, 프로그래밍 언어 나 플랫폼에 독립적이다. 표현할 수 있는 기본 자료형은 수, 문자열, 참/거짓, null이 있고, 집합 자료형으로는 배열과 객체가 있다. 기본자료형8진수와 16진수를 표현하는 방법은 지원 안 됨정수42 1974 750 -114 -273 실수 (고정 소수점)3.14 -2.718 실수 (부동 소수점)1e4 2.5e12 3.4e+4 4.56e-8 5.67E+10 6.78E-5 문자열큰 따옴표(")로 묶어야 한다.\b 백스페이스\f 폼 피드\n 개행\r 캐리지 리턴\t 탭\" 따옴표\/ 슬래시\\ 역슬래시\uHHHH 16.. 더보기
Jsoup로 파싱하기 Jsoup에서 라이브러리 다운받기http://jsoup.org/download 라이브러리를 프로젝트에 추가한다. connect 메서드로 연결할 사이트의 url을 파라미터로 넘겨준다.select 메서드에서 찾고자 하는 값의 위치를 입력한다.PatternMatchesExample*any element*tagelements with the given tag namedivns|Eelements of type E in the namespace nsfb|name finds elements#idelements with attribute ID of "id"div#wrap, #logo.classelements with a class name of "class"div.left, .result[attr]elements wi.. 더보기
강제로 예외 발생시키기 throw는 강제로 예외를 발생시키는 것발생시킨 예외는 try catch문으로 잡아줄 수 있다. 예제public void ExceptionTest(){Exception e = new Exception();throw e;} throws는 예외를 전가시킨다.예외를 자신이 처리하지 않고 자신을 호출하는 메소드에게 책임을 전가 시킨다. 예제public void ExceptionTest() throws Exception{ //throws로 예외를 전가 시킨다.Exception e = new Exception();throw e;} 더보기
XmlPuulParser로 파싱하기 public static void Parsing(){ try{ String url = "http://www.naver.com"; URL targetURL = new URL(url); InputStream is = null; is = targetURL.openStream(); boolean divtype = false; XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); XmlPullParser parser = factory.newPullParser(); //parser.setInput(new StringReader(xml)); parser.setInput(is, "utf-8"); int eventType = parser.getEventT.. 더보기
HTML 읽기 String downloadURL(String addr) { String doc = ""; try { URL url = new URL(addr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); if (conn != null) { conn.setConnectTimeout(10000); conn.setUseCaches(false); if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { // 연결이 // 완성이됫다 BufferedReader br = new BufferedReader( new InputStreamReader(conn.getInputStream())); for (;;) {.. 더보기
Pxssh로 SSH 패스워드 공격 pxssh로 ssh에 접속하기Pxssh는 pexpect 라이브러리에 있는 특화된 스트립트이다.SSH 세션과 직접 연동할 수 있는 기능이 있으며 login(), logout(), prompt() 같이 이미 딕셔너리에 정의된 메소드도 있다. import pxssh def send_command(s, cmd): s.sendline(cmd) s.prompt() print s.before def connect(host, user, password): try: s = pxssh.pxssh() s.login(host, user, password) return s except: print '[-] Error Connecting' exit(0) s = connect('127.0.0.1', 'root', 'toor') s.. 더보기
Pexpect로 SSH 연결하기 pexpect.sourceforge.net 에서 모듈을 다운받아 설치한다. (프로그램 작동, 프로그램에서 기대하고 있는 결과값 보기, 그리고 기대하고 있는 결과값으 바탕으로 응답하기 기능이 있음)tar xvzf pexpect-2.3.tar.gz cd pexpect-2.3python setup.py install import pexpect PROMPT = ['# ','>>> ','> ','\$ '] def send_command(child, cmd): child.sendline(cmd) child.expect(PROMPT) print child.before def connect(user, host, password): ssh_newkey = 'Are you sure you want to continue c.. 더보기