Skip to content

Commit b519d62

Browse files
committed
fix: lab8 no angr
1 parent 3cbac11 commit b519d62

4 files changed

Lines changed: 20 additions & 82 deletions

File tree

.github/workflows/lab-autograding.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,7 @@ jobs:
5656
if [ ${{ steps.lab.outputs.result }} -eq 6 ]; then
5757
sudo apt install -y llvm-14
5858
fi
59+
if [ ${{ steps.lab.outputs.result }} -eq 8 ]; then
60+
python3 -m pip install angr
61+
fi
5962
./validate.sh

lab4/main_test.js

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,22 @@
11
const puppeteer = require('puppeteer');
2-
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
2+
33
(async () => {
44
// Launch the browser and open a new blank page
5-
const browser = await puppeteer.launch({ headless: false });
5+
const browser = await puppeteer.launch();
66
const page = await browser.newPage();
77

88
// Navigate the page to a URL
99
await page.goto('https://pptr.dev/');
1010

11-
await page.click('button.DocSearch');
12-
await page.waitForSelector('input.DocSearch-Input');
13-
await page.type('input.DocSearch-Input', 'andy popoo');
14-
await new Promise(resolve => setTimeout(resolve, 1000));
15-
await page.waitForSelector('section.DocSearch-Hits');
16-
17-
const sections = await page.$$('section.DocSearch-Hits');
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
1819

19-
for (const section of sections) {
20-
const sourceDiv = await section.$('div.DocSearch-Hit-source');
21-
22-
if (sourceDiv) {
23-
const text = await sourceDiv.evaluate(el => el.innerText.trim());
24-
if (text === 'ElementHandle') {
25-
// Click on the first result in this section
26-
const firstListItem = await section.$('#docsearch-list li');
27-
if (firstListItem) {
28-
await firstListItem.click();
29-
await new Promise(resolve => setTimeout(resolve, 1000));
30-
const title = await page.evaluate(() => {
31-
return document.querySelector("div.theme-doc-markdown > header > h1").innerText;
32-
});
33-
console.log(title);
34-
} else {
35-
console.log('No list item found in this section');
36-
}
37-
}
38-
39-
} else {
40-
console.log('No ElementHandle found in this section');
41-
}
42-
}
43-
20+
// Close the browser
4421
await browser.close();
45-
})();
46-
22+
})();

lab5/antiasan.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,5 @@
22

33
void antiasan(unsigned long addr)
44
{
5-
unsigned long shadow_base = 0x7fff8000;
6-
unsigned char *shadow = (unsigned char *)((addr >> 3) + shadow_base);
75

8-
for (int i = 0; i < 64; i++) {
9-
shadow[i] = 0;
10-
}
11-
12-
for (int i = 1; i <= 8; i++) {
13-
shadow[-i] = 0;
14-
}
156
}

lab6/llvm-pass.so.cc

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,13 @@ struct LLVMPass : public PassInfoMixin<LLVMPass> {
1111
PreservedAnalyses LLVMPass::run(Module &M, ModuleAnalysisManager &MAM) {
1212
LLVMContext &Ctx = M.getContext();
1313
IntegerType *Int32Ty = IntegerType::getInt32Ty(Ctx);
14-
PointerType *charPtrTy = Type::getInt8PtrTy(Ctx);
14+
FunctionCallee debug_func = M.getOrInsertFunction("debug", Int32Ty);
15+
ConstantInt *debug_arg = ConstantInt::get(Int32Ty, 48763);
1516

16-
// Find main()
17-
Function *mainFunc = nullptr;
18-
for (Function &F : M) {
19-
if (F.getName() == "main") {
20-
mainFunc = &F;
21-
break;
22-
}
23-
}
24-
if (!mainFunc) return PreservedAnalyses::none();
25-
26-
IRBuilder<> builder(&*mainFunc->getEntryBlock().getFirstInsertionPt());
27-
28-
FunctionType *debugType = FunctionType::get(Type::getVoidTy(Ctx), {Int32Ty}, false);
29-
FunctionCallee debugFunc = M.getOrInsertFunction("debug", debugType);
30-
Value *debugArg = ConstantInt::get(Int32Ty, 48763);
31-
builder.CreateCall(debugFunc, {debugArg});
32-
33-
Argument *argcArg = mainFunc->getArg(0); // int argc
34-
AllocaInst *argcAlloca = builder.CreateAlloca(Int32Ty, nullptr, "argc.alloca");
35-
builder.CreateStore(ConstantInt::get(Int32Ty, 48763), argcAlloca);
17+
for (auto &F : M) {
18+
errs() << "func: " << F.getName() << "\n";
3619

37-
for (auto &BB : *mainFunc) {
38-
for (auto &I : BB) {
39-
for (unsigned i = 0; i < I.getNumOperands(); ++i) {
40-
if (I.getOperand(i) == argcArg) {
41-
IRBuilder<> tmpBuilder(&I);
42-
LoadInst *argcVal = tmpBuilder.CreateLoad(Int32Ty, argcAlloca);
43-
I.setOperand(i, argcVal);
44-
}
45-
}
46-
}
4720
}
48-
49-
Argument *argvArg = mainFunc->getArg(1); // char **argv
50-
Value *strPtr = builder.CreateGlobalStringPtr("hayaku... motohayaku!", "str");
51-
Value *argv1Ptr = builder.CreateGEP(charPtrTy, argvArg, ConstantInt::get(Int32Ty, 1));
52-
builder.CreateStore(strPtr, argv1Ptr);
53-
5421
return PreservedAnalyses::none();
5522
}
5623

@@ -64,3 +31,4 @@ llvmGetPassPluginInfo() {
6431
});
6532
}};
6633
}
34+

0 commit comments

Comments
 (0)