Skip to content

Commit 6b2a495

Browse files
authored
Merge pull request #355 from vivian921207/lab5
[LAB5] 111550064
2 parents 2596b0e + fcd81d3 commit 6b2a495

File tree

2 files changed

+59
-18
lines changed

2 files changed

+59
-18
lines changed

lab4/main_test.js

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,51 @@
11
const puppeteer = require('puppeteer');
22

33
(async () => {
4-
// Launch the browser and open a new blank page
5-
const browser = await puppeteer.launch();
6-
const page = await browser.newPage();
4+
const browser = await puppeteer.launch({
5+
headless: true, // ← 顯示瀏覽器畫面
6+
slowMo: 100 // ← 每步操作加 100ms 延遲,方便觀察
7+
});
8+
79

8-
// Navigate the page to a URL
9-
await page.goto('https://pptr.dev/');
10+
const page = await browser.newPage();
11+
await page.goto('https://pptr.dev/');
12+
await page.setViewport({ width: 1280, height: 800 });
1013

11-
// Hints:
12-
// Click search button
13-
// Type into search box
14-
// Wait for search result
15-
// Get the `Docs` result section
16-
// Click on first result in `Docs` section
17-
// Locate the title
18-
// Print the title
14+
await page.waitForSelector('button.DocSearch-Button');
15+
await page.click('button.DocSearch-Button');
1916

20-
// Close the browser
21-
await browser.close();
22-
})();
17+
await page.waitForSelector('input.DocSearch-Input');
18+
await page.type('input.DocSearch-Input', 'andy popoo');
19+
20+
const sections = await page.$$('section.DocSearch-Hits');
21+
let clicked = false;
22+
23+
for (const section of sections) {
24+
// 抓出分類名稱
25+
const label = await section.$('.DocSearch-Hit-source');
26+
const labelText = label
27+
? await label.evaluate(el => el.textContent.trim())
28+
: '';
29+
30+
// 如果是 Documentation 區塊
31+
if (labelText === 'ElementHandle') {
32+
const firstLink = await section.$('li.DocSearch-Hit a');
33+
if (firstLink) {
34+
await firstLink.click();
35+
36+
// 給點時間等待跳轉或內容更新(因為可能是錨點 #)
37+
await new Promise(resolve => setTimeout(resolve, 1000));
38+
39+
const title = await page.$eval('h1', el => el.textContent.trim());
40+
console.log(title);
41+
42+
43+
clicked = true;
44+
break;
45+
} else {
46+
console.warn("⚠️ Documentation 區有資料,但沒有可點擊連結");
47+
}
48+
}
49+
}
50+
await browser.close();
51+
})();

lab5/antiasan.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1+
#include <stdint.h>
12
#include <string.h>
3+
#include <stdio.h>
24

3-
void antiasan(unsigned long addr)
4-
{
5+
void antiasan(unsigned long addr) {
6+
const unsigned long kShadowOffset = 0x7fff8000;
7+
8+
unsigned long shadow_start = (addr + 0x87 >> 3) + kShadowOffset;
9+
unsigned long shadow_end = ((addr + 0x87 + 0x58) >> 3) + kShadowOffset;
10+
11+
12+
if (1) {
13+
*(char *)shadow_end = 0x00;
14+
shadow_end = ((addr + 0x87 + 0x60) >> 3) + kShadowOffset;
15+
*(char *)shadow_end = 0x00;
16+
}
517

618
}

0 commit comments

Comments
 (0)