202401to07
  • 2024.06.04.보안 day42
    2024년 06월 04일 10시 50분 35초에 업로드 된 글입니다.
    작성자: 202401to07


    DB의 제약조건: 

    primary 

    unique

    not null 

    foreign


    cascade   부모 삭제/변경시 자식데이터 동기화  -> 동기화 모드 
    set null 부모 데이터 삭제시 해당 자식 데이터 null
    set default 부모데이터 삭제시 해당 자식 데이터 기본값
    Restrict 자식 테이블에 데이터 남아있는경우       --> 감시모드 
                    부모 테이블의 삭제 또는 변경 불가

     

    MySQL은 크게 서버 엔진과 스토리지 엔진 두 가지 구조로 되어있다.

    스토리지 엔진
    물리적 저장장치에서 데이터를 읽어온다.

    종류

     :

    InnoDB

    복잡하다
    스토리지 엔진의 default 
    transaction-safe
    커밋 , 롤백, 데이터 복구 기능 제공
    row-level locking을 제공 (외에도 다양한 종류의 lock이 있긴하다)
    동시 처리에 효과적이나, deadlock이 발생할 수 있다.
    clustered index에 저장하여 Primary Key 기반의 query의 I/O 비용을 줄인다.
    외래키를 허용해 무결성을 보장.
    단순 select 기능에서는 MyISAM에 비해 안좋은 성능

    MyISAM

    간단하다
    트랜잭션을 지원X
    table 단위로 locking을 제공/  멀티 스레드 환경에 부적합하다
    읽기 위주의 간단한 작업에 적합
    대량의 insert를 하는 배치 작업에 적합
    비교적 작은 웹에도 적합하다.

    Archive

    로그 수집, 원시 로그 데이터 관리에 적합한 엔진
    메모리 상에서 압축된 상태로 저장
    row-level locking이 가능
    한번 insert된 데이터는 update나 delete가 불가능
    인덱스 지원 안함
    테이블 파티셔닝 지원
    트랜잭션은 지원X

    ENGINE=InnoDB

     마지막 부분의 ENGINE=InnoDB; 와 같은 구문을 첨가함으로써 InnoDB 테이블을 생성 가능하다.

     

    select engine from information_schema.engines where support='default';    : 디비 확인

    +--------+
    | engine |
    +--------+
    | InnoDB |
    +--------+

     

    select * from information_schema.table_constraints where table_name='ord';

    show index in ord;

    show index from ord;

    show create table ord;     : 만든 테이블 보기


    웹해킹

     

    게시판 DB
    create table b_tb(
    b_no    int  unsigned  auto_increment not null,
    subject char(100) not null,
    user     char(20) not null,
    contents text not null,
    reg_date datetime,
    index(b_no),
    unique key no(b_no));


    회원가입 DB
    create table class (
        c_no int unsigned auto_increment not null,
        id char(40) not null,
        pw char(40) not null,
        nick varchar(40) not null,
        date datetime not null,
        index(c_no),
        primary key(id),
        unique key sevas1(c_no),
        unique key sevas2(c_no,id));


    파일 업로드 DB
    create table file_tb(
    file_no int not null auto_increment,
    file_name char(255) not null,
    reg_date datetime,
    file_own char(20),
    file_size char(10),
    primary key(file_no));

     

    +-----------------+
    | Tables_in_sevas |
    +-----------------+
    | b_tb            |
    | class           |
    | file_tb         |
    +-----------------+ㅣ

     

     alter database sevas default character set = utf8; 
    한글설정 코드 
    한글설정 후 테이블 생성해야 적용된다 
    생성 후에는 적용이 안된다  

     

     

    0_★웹만들기스크립트1★.txt
    0.01MB

     

     

    1. 클릭시  웹페이지 이동 
    <a href = " http://www.naver.com"> click here </a>


    2. 그림 추가
    <img src="주소" width="100" height="100"></img> here</a>

    3. 이미지 클릭시 웹페이지 이동 
    <a href ="http://www.naver.com"><img src="주소" width="100" height="100"></img></a>

     

    4. 사이트 링크 넣기
    <iframe src="https://www.nate.com" width="800" height="800" frameborder="10"></iframe>

    5. 응용 유튜브 올리기
    <iframe width="560" height="315" src="https://www.youtube.com/embed/O-IX_MrvIBU">
    <iframe width="560" height="315" src="https://www.youtube.com/embed/O-IX_MrvIBU?autoplay=1" allow="autoplay;">

    6. xxs 공격 (바로실행되도록 하기) [ Stored XSS (Persistent XSS, 저장 XSS)]
    <script> location.href="https://www.naver.com"</script>

    <script> alert ("xss test") </script>


    xss 공격 (Cross Site Scripting)
    자바스크립트를 써서 공격자가 의도한대로 사용자를 유도하는 공격

    실습 

    #1 경고창 [경고문 띄우기]

    <script> alert("안녕하세요")</script>
    <script> alert(document.cookie)</script>

    PHPSESSID=6l15fanpb40vg6f8g9p94c3l22

    '보안' 카테고리의 다른 글

    2024.06.07.보안 day44  (0) 2024.06.10
    2024.06.05.보안 day43  (0) 2024.06.09
    2024.06.03.보안 day41  (1) 2024.06.03
    2024.05.30.목.보안 day40  (0) 2024.05.30
    2024.05.29.수.보안 day39  (0) 2024.05.29
    댓글