2013년 9월 5일 목요일

로보코드 찾는 곳. - 마지막에 링크 -

/*
 * Created on Aug 4, 2003
 *
 */
package jekl.mini;
import java.awt.geom.*;
import java.io.*;
import java.util.zip.*;
import robocode.*;
import robocode.util.Utils;
public class BlackPearl extends AdvancedRobot {
        private static final double         MAX_STAND_OFF_DISTANCE         = 600D;
        private static final double         MIN_STAND_OFF_DISTANCE         = 500D;
        private static final double         GUESS_FACTORS                 = 23D;
        private static final double        MIDDLE_FACTOR                = (GUESS_FACTORS -1) / 2;
        private static final double        WALL_CURVE_DISTANCE        = 180D;                                        //pixels
        private static final int        CLOSE_IN                = -1;
        private static final int        BACK_OFF                = 1;
        private static Rectangle2D.Double field;
        private static int statBuffer[][][][][][];
        private static String targetName;
        private static int hits;
        private int direction = 1;
        private int eDirection;
        private double eEnergy = 100D;
        private double eX, eY, eDelta, eAbsBearing, eVelocity, eDistance, eHeading;
        private boolean flatten = (hits > 2);
        private double eLastShot = 3;
        private static int ticksSinceReverse = 0;
        int lastLatVelIndex = 0;
public void run() {
                //setColors(java.awt.Color.MAGENTA, java.awt.Color.LIGHT_GRAY, java.awt.Color.RED);
                field = new Rectangle2D.Double(18, 18, getBattleFieldWidth() - 36, getBattleFieldHeight() - 36);
                setAdjustGunForRobotTurn(true);
                setAdjustRadarForGunTurn(true);
                do {
                        turnRadarRightRadians(Double.POSITIVE_INFINITY);
                } while(true);
        }
       
        public void onScannedRobot(ScannedRobotEvent e) {
                //Gather target information
                targetName = e.getName();
               
                if (Math.abs(eVelocity) > Math.abs(eVelocity = e.getVelocity())) {
                        ticksSinceReverse = 0;
                }
                double latVel = (eVelocity) * Math.sin(eHeading = e.getHeadingRadians() - (eAbsBearing = Utils.normalRelativeAngle(getHeadingRadians() + (e.getBearingRadians()))));
                eX = getX() + Math.sin(eAbsBearing) * (eDistance = e.getDistance());
                eY = getY() + Math.cos(eAbsBearing) * eDistance;
//Keep the sign of the direction last used if latVel is zero
                if (latVel != 0) {
                        eDirection = (int)(Math.abs(latVel) / latVel);
                }
//Set the indicies for shooting
                int distanceIndex = (int)Math.min(4, eDistance / 180D);
               
                //Reverse chance
                if ((eDelta = eEnergy - (eEnergy = e.getEnergy())) > 0 && eDelta <= 3) {
                        eLastShot = eDelta;
                }
               
                //Set the firePower
                double firePower = (distanceIndex <=1 ? 3.0 : 1.9);
                //double firePower = (getEnergy() > 0 ? 3.0 : 0);
//Movement                
                //This is an adaptation from Raiko. If you can't beat 'em, join 'em               
                double distDelta = 0.02 + Math.PI/2 + (e.getDistance() > 400 ? -.1 : .5);
                double theta = 0.5952*bulletV(eLastShot)/eDistance;
                if ( (Math.random() > Math.pow(theta, theta)  && flatten)|| distDelta < Math.PI/4 || (distDelta < Math.PI/3 && eDistance < 400)){
                //double theta = .64 * bulletV(eLastShot)/eDistance;
                //if ((Math.random() > Math.pow(theta, theta) && flatten)) {
                        direction = -direction;
                }
//Finally move
                goTo(getDestination(new Point2D.Double(getX(), getY()),direction));
//Radar
                setTurnRadarRightRadians(Math.sin(eAbsBearing - getRadarHeadingRadians()));
//Gun
                //Initialize the statbuffer
                if (statBuffer == null) {
                        statBuffer = (int[][][][][][]) readObject(targetName);
                }
//Retrieve the current stat segment to use
                int stats[] = statBuffer[getOutIndex()][lastLatVelIndex][(lastLatVelIndex = ((int)Math.abs(latVel) / 2))][Math.min(4, ++ticksSinceReverse/10)][distanceIndex];
//Get the current best Guess Factor to shoot at
                int bestIndex = (int)MIDDLE_FACTOR;
                for (int i = 0; i < stats.length ; i++) {
                        if (stats[i] > stats[bestIndex])
                                bestIndex = i;
                }
                
//Aim the gun
                //Original
                setTurnGunRightRadians(Utils.normalRelativeAngle(eAbsBearing - getGunHeadingRadians() + (getGuessAngle(bestIndex, firePower))));
if (firePower > 0) {
                        setFire(firePower);
                        Wave w = new Wave();
                        w.guessFactors = stats;
                        w.wDirection = eDirection;
                        w.bulletVel=bulletV(firePower);
                        w.dist+=w.bulletVel;
                        w.shotOrigin = new Point2D.Double(getX(), getY());
                        w.startingAbsTargetBearing = eAbsBearing;
                        w.maxAnglePossible = Math.asin(8.0 / w.bulletVel);
                        addCustomEvent(w);
                }
                //lastLatVelIndex = latVelIndex;
        }
       
        // Check if we are hit with full lead aim
        // Adapted from Axe's Musashi: http://robowiki.net/?Musashi
        public void onHitByBullet(HitByBulletEvent e) {
                //if (ticksSinceReverse > (eDistance / e.getVelocity()) && !flatten) {
                if (!flatten) {
                        flatten = (++hits > 0);
                }
        }
// Save the data if I win the round
        public void onWin(WinEvent e) {
                try {
                        ObjectOutputStream  oos = new ObjectOutputStream(new GZIPOutputStream(new RobocodeFileOutputStream(getDataFile(targetName))));
                        oos.writeObject(statBuffer);
                        oos.close();
                } catch (IOException ex) {
                        //Should do something here but alas it is too big
                        //e.printStackTrace();
                }
        }
// Figures the Guess Angle Radians to offset the gun by
        private double getGuessAngle(int guessIndex, double firePower) {
                if (eEnergy == 0.0) //If the enemy bot is disabled, fire directly at it.
                        return 0.0;
                return (guessIndex - MIDDLE_FACTOR) / MIDDLE_FACTOR * Math.asin(8.0 / bulletV(firePower)) * eDirection;
        }
// Method to read data from disc. Taken from SandboxMini
        Object readObject(String fileName) {
                try {
                        ObjectInputStream ois = new ObjectInputStream(new GZIPInputStream(new FileInputStream(getDataFile(fileName))));
                        Object o = ois.readObject();
                        ois.close();
                        return o;
                } catch (Exception e) {
                        //int stats[] = statBuffer[getOutIndex()][lastLatVelIndex][latVelIndex][Math.min(4, ++ticksSinceReverse/5)][distanceIndex];
                        return new int[5][5][5][5][5][(int)GUESS_FACTORS];
                        //Should do something here but alas it is too big
                        //e.printStackTrace();
                }
        }
       
        //Retrieve the bullets velocity
        private double bulletV (double shotPower) {
                return (20 - (3 * shotPower));
        }
       
        //Gets the point we are going to aim for in the next tick
        private Point2D.Double getDestination(Point2D.Double startFrom, int direct) {
                double fudge = 0;        //Adjustment to rotate the heading by
                Point2D.Double dest = new Point2D.Double();
                //If we are  in the "sweet spot" no need to move in or out
                double dir = eAbsBearing + (Math.PI / 2) + (.2618 * direct * (eDistance > MAX_STAND_OFF_DISTANCE ? CLOSE_IN : (eDistance < MIN_STAND_OFF_DISTANCE ? BACK_OFF : 0)));
                int counter = 0;
                //Rotate the position we are heading for until it is in the field
                do {
                        dest.setLocation(startFrom.x + Math.sin(dir + (fudge * direct)) * WALL_CURVE_DISTANCE * direct,
                                startFrom.y + Math.cos(dir + (fudge * direct)) * (WALL_CURVE_DISTANCE * direct));
                        fudge-=.0085;        //.5 degrees radians
                } while (!field.contains(dest) && ++counter < 180);
                if (counter >= 55 && flatten) {
                        direction = -direction;
                }
                return dest;
        }
//This moves me about the field
        private void goTo(Point2D destination) {
                ticksSinceReverse++;
                double angle = Utils.normalRelativeAngle(Math.atan2((destination.getX() - getX()), (destination.getY()- getY())) - getHeadingRadians());
                double turnAngle = Math.atan(Math.tan(angle));
                setTurnRightRadians(turnAngle);
                setAhead(destination.distance(getX(), getY()) * (angle == turnAngle ? 1 : -1) * Math.cos(turnAngle));
        }
               
        //Return the wall index
        private int getOutIndex() {
                int i = 0;
                do {
                       
                } while (++i < 4 && field.contains((eX + (Math.sin(eHeading)* (45.0 * i) * eDirection)), (eY + (Math.cos(eHeading) * (45.0 * i) * eDirection))));
                return (i);
        }
       
        // Jekyl's implementation of a Wave (mostly)
        public class Wave extends Condition {
                public Point2D.Double shotOrigin;
                public double bulletVel;
                public double dist;
                public double startingAbsTargetBearing;
                public double maxAnglePossible;
                public int[] guessFactors;
                public int wDirection;
public boolean test() {
                        if ((dist+=bulletVel) >= shotOrigin.distance(eX,eY) - 18) {
                                double currentAbsBearingFromShotOrigin = Math.atan2(eX - shotOrigin.getX(), eY - shotOrigin.getY());
                                guessFactors[(int)Math.max(0, Math.min((GUESS_FACTORS - 1),(int) Math.round(((((Utils.normalRelativeAngle(currentAbsBearingFromShotOrigin - startingAbsTargetBearing) * wDirection) / maxAnglePossible) * MIDDLE_FACTOR) + MIDDLE_FACTOR))))]++;
                                removeCustomEvent(this);
                        }
                        return false;
                }
        }  //End Wave
}

I will follow you into the dark 기타 악보

http://tabs.ultimate-guitar.com/d/death_cab_for_cutie/i_will_follow_you_into_the_dark_ver5_crd.htm

여기 좋네~



SELINUX 019

  1. Chown the entire /var/www/html hierarchy to root:apache and make it readable for user and group only:
  • chown -R root:apache /var/www/html
  • chmod -R g-w,o-rwx /var/www/html
  1. Create (if it doesn’t already exist) and chown /var/www/html/wordpress/wp-content/uploads to apache:apache and make sure it’s user-writable (it should already be):
  • mkdir /var/www/html/wordpress/wp-content/uploads
  • chown -R apache:apache /var/www/html/wordpress/wp-content/uploads
  • chmod -R u+w,g-w,o-rwx /var/www/html/wordpress/wp-content/uploads
  1. Change the SELinux context of /var/www/hml/wordpress/wp-content/uploads to httpd_sys_rw_content_t:
  • chcon -R –type=httpd_sys_rw_content_t /var/www/html/wordpress/wp-content/uploads
  1. Optionally, make the change permanent, i.e., make it survive a complete file system re-label:
  • semanage fcontext -a -t httpd_sys_rw_content_t “/var/www/html/wordpress/wp-content/uploads(/.*)?”


여기서 찾은 자료인데 chown과 chcon 사용법을 비교할 수 있을 것 같다.

SELINUX 018

To list


1. access vector binder receive 삭제
2. unconfined domain 추가
  • Adbd

  • Platform_app
  • Media_app
  • Shared_app
  • Release_app
  • Isolated_app
  • Untrusted_app

  • Bluetooth
  • Dbusd
  • Deburged
  • Dhcp
  • Drmserver
  • Gpsd
  • Installd
  • Keystore
  • Media_server
  • Mtp
  • Netd
  • Qemud






  1. 타입 추가
  • Sensors
  • Owntty_device
  • Iio_device
  • Ion_device
  • Watchdog_device
  • Uhid_device
  • Tun_device
  • Usbaccessory_device
  • Klog_device
  • Properties_device
  •  

  1. Domain.te 삭제
  2. File_context 변경
  • 추가
/                        u:object_r:rootfs:s0

# Data files
/adb_keys                u:object_r:rootfs:s0
/default.prop                u:object_r:rootfs:s0
/fstab\..*                u:object_r:rootfs:s0
/init\..*                u:object_r:rootfs:s0
/res(/.*)?                u:object_r:rootfs:s0
/ueventd\..*                u:object_r:rootfs:s0

# Executables
/charger                u:object_r:rootfs:s0
/init                        u:object_r:rootfs:s0
/sbin(/.*)?                u:object_r:rootfs:s0

# Empty directories
/lost\+found                u:object_r:rootfs:s0
/proc                        u:object_r:rootfs:s0
/sys                        u:object_r:rootfs:s0

# SELinux policy files
/file_contexts                u:object_r:rootfs:s0
/property_contexts        u:object_r:rootfs:s0
/seapp_contexts                u:object_r:rootfs:s0
/sepolicy                u:object_r:rootfs:s0
/dev/bus/usb(.*)?       u:object_r:usb_device:s0
/dev/iio:device[0-9]+   u:object_r:iio_device:s0
/dev/mpu                u:object_r:gps_device:s0
/dev/mpuirq                u:object_r:gps_device:s0
/dev/socket/adbd        u:object_r:adbd_socket:s0
/dev/socket/racoon        u:object_r:racoon_socket:s0
/dev/tty                u:object_r:owntty_device:s0
/dev/tun                u:object_r:tun_device:s0
/dev/uhid                u:object_r:uhid_device:s0
/dev/usb_accessory        u:object_r:usbaccessory_device:s0
/dev/watchdog                u:object_r:watchdog_device:s0
/dev/__kmsg__                u:object_r:klog_device:s0
/dev/__properties__ u:object_r:properties_device:s0
/system/bin/run-as        --        u:object_r:runas_exec:s0
/system/bin/bluetoothd        u:object_r:bluetoothd_exec:s0
/system/bin/racoon        u:object_r:racoon_exec:s0
/system/bin/ping    u:object_r:ping_exec:s0
/vendor(/.*)?                u:object_r:system_file:s0
/vendor/bin/gpsd        u:object_r:gpsd_exec:s0
/data/backup(/.*)?                u:object_r:backup_data_file:s0
/data/secure/backup(/.*)?        u:object_r:backup_data_file:s0
/data/security(/.*)?        u:object_r:security_file:s0
/data/app-private(/.*)?                u:object_r:apk_private_data_file:s0
/data/app-private/vmdl.*\.tmp        u:object_r:apk_private_tmp_file:s0
/data/local/tmp(/.*)?        u:object_r:shell_data_file:s0
/data/local/tmp/selinux(/.*)?   u:object_r:tombstone_data_file:s0
/data/misc/bluetoothd(/.*)?        u:object_r:bluetoothd_data_file:s0
/data/misc/bluedroid(/.*)?        u:object_r:bluetooth_data_file:s0
# Wallpaper file for other users
/data/system/users/[0-9]+/wallpaper                u:object_r:wallpaper_file:s0
# Downloaded files
/data/data/com.android.providers.downloads/cache u:object_r:download_file:s0
/cache/.*\.data        u:object_r:cache_backup_file:s0
/cache/.*\.restore        u:object_r:cache_backup_file:s0
# LocalTransport (backup) uses this directory
/cache/backup(/.*)?        u:object_r:cache_backup_file:s0
/sys/class/rfkill/rfkill[0-9]*/state -- u:object_r:sysfs_bluetooth_writable:s0
/sys/class/rfkill/rfkill[0-9]*/type -- u:object_r:sysfs_bluetooth_writable:s0
/mnt/asec(/.*)?         u:object_r:asec_apk_file:s0
/data/app-asec(/.*)?    u:object_r:asec_image_file:s0


  1. Permissive keyword 추가
  2. Keys.conf 추가

exploit 성공...

[*] by Dan Rosenberg (@djrbliss)
[*]
[*] Tested on the Motorola Razr HD, Razr M, Razr Maxx HD, an
[*] Supports lots of other devices as well. ;-)
[*]
[*] Before continuing, ensure that USB debugging is enabled,
[*] have the latest USB drivers installed, and that your pho
[*] is connected via USB.
[*]
[*] WARNING: This will likely void the warranty on your devi
[*] not responsible for any damage to your phone as a result
[*] tool.
[*]
[*] Press enter to root your phone...
계속하려면 아무 키나 누르십시오 . . .
[*]
[*] Waiting for device...
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
[*] Device found.
[*] Pushing exploit...
5310 KB/s (1283460 bytes in 0.236s)
[*] Pushing root tools...
4166 KB/s (366952 bytes in 0.086s)
4724 KB/s (1867568 bytes in 0.386s)
4416 KB/s (1578585 bytes in 0.349s)
        pkg: /data/local/tmp/Superuser.apk
Success
[*] Rooting phone...
[+] This may take a few minutes.
[-] Failure.
[*] Cleaning up...
[*] Exploit complete. Press enter to reboot and exit.

젤리빈+에서도 되네 ㅠㅠ

SELINUX 017

    • libsepol is the binary policy manipulation library. Libsepol은 바이너리 정책 조작 라이브러리며,
    • It doesn't depend upon or use any of the other components. 다른 컴포넌트에 종속적이지 않다.
    • checkpolicy is the policy compiler. It uses libsepol to generate the binary policy. checkpolicy uses the static libsepol since it deals with low level details of the policy that have not been encapsulated/abstracted by a proper shared library interface. Checkpolicy는 정책 컴파일러다. Libsepol을 이용하여 바이너리 policy를 만든다. 정적인 libsepol 을 사용한다. 알맞은 공용 라이브러리에 의해 캡슐화/추상화되지 않은 정책의 하부 상세와 결합된다.
    • -> 해석은 애매하다. 소스를 보니 걍 둘다 생성한다고 이해하면 되겠다.
    •  libsepol의 Android.mk 를 보면 libsepol 정적 라이브러리 생성과 동적라이브러리 생성이 함께 있다.
    ##
    # libsepol.so
    #
    include $(CLEAR_VARS)

    LOCAL_MODULE := libsepol
    LOCAL_MODULE_TAGS := optional
    LOCAL_C_INCLUDES := $(common_includes)
    LOCAL_CFLAGS := $(common_cflags)
    LOCAL_SRC_FILES := $(common_src_files)
    LOCAL_MODULE_CLASS := SHARED_LIBRARIES

    include $(BUILD_HOST_SHARED_LIBRARY)

    ##
    # libsepol.a
    #
    include $(CLEAR_VARS)

    LOCAL_MODULE := libsepol
    LOCAL_MODULE_TAGS := optional
    LOCAL_C_INCLUDES := $(common_includes)
    LOCAL_CFLAGS := $(common_cflags)
    LOCAL_SRC_FILES := $(common_src_files)
    LOCAL_MODULE_CLASS := STATIC_LIBRARIES

    include $(BUILD_HOST_STATIC_LIBRARY)


    • libselinux is the runtime SELinux library that provides interfaces (e.g. library functions for the SELinux kernel APIs like getcon(), other support functions like getseuserbyname()) to SELinux-aware applications. libselinux may use the shared libsepol to manipulate the binary policy if necessary (e.g. to downgrade the policy format to an older version supported by the kernel) when loading policy. 걍 의역 Libselinux는 런타임 SELinux 라이브러리이다. SELinux의 커널 API사용이나 libsepol을 이용한 policy 조작 같은.
    • libsemanage is the policy management library. It uses libsepol for binary policy manipulation and libselinux for interacting with the SELinux system. It also exec's helper programs for loading policy and for checking whether the file_contexts configuration is valid (load_policy and setfiles from policycoreutils) presently, although this may change at least for the bootstrapping case (for rpm).
    • Libsemanager는 정책 관리 라이브러리이다. Libsepol, libselinux 둘다 이용한다. Policy 로딩이나 체킹들을 한다. Semanage라는 유틸이 있는데 libsemanage를 이용하는 것 같다.
    emanage(8)                                                                                                                                      semanage(8)

    NAME
           semanage - SELinux Policy Management tool

    SYNOPSIS
           semanage {boolean|login|user|port|interface|node|fcontext} -{l|D} [-n] [-S store]
           semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean | boolean_file
           semanage login -{a|d|m} [-sr] login_name | %groupname
           semanage user -{a|d|m} [-LrRP] selinux_name
           semanage port -{a|d|m} [-tr] [-p proto] port | port_range
           semanage interface -{a|d|m} [-tr] interface_spec
           semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask] address
           semanage fcontext -{a|d|m} [-frst] file_spec
           semanage permissive -{a|d} type
           semanage dontaudit [ on | off ]


    • sepolgen is a python module/library that forms the core of the modern audit2allow (a rewrite).
    • Sepolgen은 파이썬 모듈/라이브러리고 현재 audit2allow의 핵심을 구성한다.
    • policycoreutils is a collection of policy utilities (originally the "core" set of utilities needed to use SELinux, although it has grown a bit over time), which have different dependencies. sestatus, secon, run_init, and newrole only use libselinux. load_policy and setfiles only use libselinux and libsepol. semodule and semanage use libsemanage (and thus bring in dependencies on libsepol and libselinux as well). setsebool uses libselinux to make non-persistent boolean changes (via the kernel interface) and uses libsemanage to make persistent boolean changes.
    • Policycoreutils는 policy유틸들의 집합.
    • Apt-get install policycoreutils하면 깔린다.

2013년 9월 3일 화요일

글보다 끄적.

it will require from each dll. 그것들은 다른 dll에서 요구될 것이다.
Because the function addresses are not static, 왜냐면 함수 주소는 고정된게 아니기 때문이다.
a mechanism was developed that 메카니즘은 다음과 같이 개발되어졌다.
allows for these variables to be changed without needing to alter all of the compiled code at runtime. 실행시간에 컴파일된 코드들이 고쳐지지 않고 이 변수들이 바뀌는게 가능하도록
This was accomplished through the use of an import address table (IAT). 이것은 IAT를 통해서 완성되었다.
This is a table of function pointers filled in by the windows loader  이것은 윈도우 로더에 의해 채워진 펑션 포인터들의 테이블이다.
as the dlls are loaded.  dll이 로드될 때
When the application was first compiled, 어플이 처음 컴파일 될 때
it was designed 그것은 디자인 된다.
so that none of the API calls use direct hardcoded addresses 그래서 어떤 코드도 주소가 바로 고정되어 사용되지 않는다.
but rather work through a function pointer. 그래서 함수 포인터를 이용한다

이전 내 만담글

여러 운영체제를 그냥 써보기만 했지만 각자 장단점이 있습니다.
네트웍은 단연 리눅스가 우위고, 멀티미디어는 윈도우가 독보적이죠.
사실 리눅스에 베릴 컴피즈 깔아서 화면 큐브로 돌리고 창을 젤리처럼 움직여 볼 때는 아...
리눅스가 데탑도 더 괜찮구나! 했슴죠. 그런데 정작 게임을 하려면 윈도우로 와야 했고.
관련 APP들 중 게임만 봐도 리눅스가 가야할 길은 너무도 멀어 보입니다.

그리고 여러회사에서 돈을 내고 기부를 통하고 사비를 털어서 리눅스 패키징을 하고 있지만
마소의 자금력을 따라가기는 힘들어서 앞으로도 리눅스는 공부의 도구, 데스크탑 이외의 시장에서
힘을 발휘하리라 생각이 됩니다.

사실 리눅스 강좌4는 네트웍 이야기 인데 리눅스나 윈도우나 같습니다. 그럼, 유닉스 솔라리스 등등도
같은 거죠.

흠흠 그럼 시작 할게요.

우선 네트웍 이라고 하면 랜선을 통해서 전기적 신호를 주고 받는 것을 말합니다.

종이컵 2개를 실로 연결해서 전화기로 사용을 하던 시절이 있었지요?


그것처럼 랜선도 우리의 신호를 전달해 줍니다. UTP 케이블이란 용어도 쓰는데요. 랜선 양쪽에 달린 RJ45 꼭다리까지
포함해서 걍 랜선이라고 합니다.

랜선으로 컴터 2대 직접 연결되면 그 케이블은 크로스 케이블이라고 하고, 허브를 통해서 연결되면 다이렉트 케이블이라고 합니다.
크로스 케이블은 2번 4번 케이블(기억이 가물가물 2,6이던가...)이 반대로 되어 있어요. 왜냐면 입력/출력이 바뀌어서 컴터로 들어가야 하니까.

 요즘은 인터넷 공유기가 워낙 싸져서 크로스 케이블 이용은 안해도 다 다이렉트 케이블 입니다.

상식적으로 이어폰을 무진장 길게하면 음악이 들릴까요? 전기적 신호도 세기가 있습니다. 케이블도 길어지면 안되거든요.
전에 친구집가서 옥상으로 다락방 컴터 연결한다고 랜선을 길게 제작했더니 인터넷이 끊겼다가 연결되었다가 자꾸 그러더라구요. 대략 10미터였나?

랜선은 너무 길면 안됩니다. 길게 하려면 리피터라는 것을 이용해서 다시 약해진 신호를 복구 시켜 줘야 하죠. 근데 실생활에 쓸일이 없으니까
다나와에서 리피터를 찾은 기억은 없네요.

우선 그렇게 랜선이 연결되게 되면 어딘가에 있는 gateway라는 놈을 통해서 인터넷 정보를 받을 수가 있습니다.
사실 집에 있는 인터넷 공유기도 하나의 gateway라고 보시면 되요. 허브랑 게이트웨어 인터넷 공유기등을 구분짓는 건 간단합니다.
허브는 IP 공유가 안되는 인터넷 공유기예요. 게이트웨이는 다른 네트웍과 연결이 되는 통로라고 보시면 되요.
IP공유기도 일종의 게이트웨어라고 볼 수 있습니다. 메가패쓰랑 연결되니까. KT에서 나오는 유선이랑 LAN이란 변환시켜주는 것도 게이트웨이
라고 볼 수가 있겠네요. 사실 꼼꼼히 따지면 다 다른 거지만 엔지니어가 보는 눈엔 별 차이가 없네요.

 그러면 인터넷은 게이트웨이 에서 어떻게 오느냐? 랜카드를 통해서 오죠. 간단.
랜카드가 전기적 신호를 우리는 모르지만 좀 더 구체화 시켜줍니다. 그럼 늘 말하는 TCP/IP는? 그 구체화 된걸 더 구체화 시켜주는 거죠.
그럼 전기적 신호는 어떻게 우리 집을 찾아 오는 걸까?

윈도키 + R 누르시면 명령창이 뜨는데 cmd라고 쳐 보세요. 리눅스에서는 걍 치면 되겠죠.

arp -a 라고 치면 현재 arp 패킷을 받는 컴퓨터들(정확히는 랜카드)들의 주소가 나옵니다. 보통 맥어드레스라고 불러요.

arp -a 쳤는데 아무것도 안 나오면 일단 랜카드가 안된다고 보시면 되요. 그 맥 어드레스 위에는 IP가 올라갑니다. 우리가 임의대로 바꿀 수 있는 거죠.

윈도우 에서는 ipconfig /all, 리눅스에서는 ifconfig 로 확인을 할 수 있습니다.

ping이 해당 IP로 패킷을 날리는 명령어 인데

자신의 gateway를 보고 ping gateway-IP 예)ping 123.222.333.222 로 핑을 날렸을 때 핑이 날아가면 게이트웨이까지 연결은 이상이 없다는 뜻입니다.

즉, arp가 안되면 하드웨어적(랜선 손상이나 잭 손상, 랜카드 손상)문제가 있는거고, ping이 안 날아가면 소프트웨어 적으로 문제기 있다고 보시면 됩니다.

IP 설정 잘못되었던지 gateway가 문제가 있다던지 TCP/IP 프로토콜 이상이라던지... 통산 게이트웨이라고 불리는 녀석들은

ping을 받습니다. 서버같은 것들은 PING을 막는 경우도 있습니다. ping 공격이란것도 있어서 무쟈게 핑을 많이 때리면 서버가 죽어서 리눅스 설정중에

icmp 무시기 ignore 세팅을 해주면 핑에 대해서 응답을 안합니다.

자 그럼 이것들을 왜 알아야 할까요?

arp에서 확인하셨을수도 있지만. 사실 내 컴퓨터는 다른 애들이 받는 정보도 다 같이 받고 있습니다. 하지만 자기 정보만 골라서 쇽쇽 받고 있쬬.

그걸 푸는게 리눅스에서 가능한데요(윈도는 안해봐서) PROMISC 모드란 것을 설정해 줍니다.

 그럼 다른 컴으로 가는 패킷도 다 받을 수 있습니다. 문제는 비싼 게이트 웨어는 PROMISC 모드로 안 쏴주거든요(하지만 별도의 포트가 꼭 있습니다)

그렇게 받아서 tcpdump 를 뜬게 이전 글이었습니다.

 신기한게 암호화 되지 않은 아스키는 그냥 나오는 거죠. 분석할 필요도 없이 연결된 아스키 값이기 때문에 패스워드를 찾기가 매우 쉽습니다.(ID만 알면 찾기로

찾아 버리면 되지요) 패킷은 전기적 신호가 온걸 드라이버 단에서 올려주고 TCP/IP라는 녀석들이 그들이 정한 약속으로 패키징을 한 뭉태기를 말합니다.


 이런 패킷을 훔쳐 보는게 스니핑이죠. 그리고 변조할 수도 있습니다. 담 시간에는 네트웍 프로그래밍 한번 할께요..


흠... 어줍잖은 이론 강의 조금 적었는데 제대로 설명을 했나 모르겠네용~

2013년 9월 1일 일요일

중급 리눅스 키워드

nm
gcc -E -S -c -v

time
addr2line
objcopy,, objdump
size
strip -R 
__asm__
__volitile
DDD
strace
ltrace

대학원생의 투고 지도 ④ (완결) — 논문의 수준이란 무엇인가: 사다리와 사분위, 첫 논문 전략

완결편이다. "논문 수준"이라는 말을 해부하고, 에듀테크 석사생의 첫 논문 전략으로 마친다. 학위논문과 학술지 논문은 다른 장르다 먼저 가장 흔한 혼동부터. 학위논문(thesis)은 "내가 연구를 수행할 줄 안다...