defdeletebook(bookId): io.recv() io.sendline("2") io.sendlineafter('Enter the book id you want to delete: ', str(bookId))
defedit_book(bookId, desc): io.recv() io.sendline('3') io.sendlineafter('Enter the book id you want to edit: ', str(bookId)) io.sendlineafter('Enter new book description: ', desc)
动态调用(DInvoke)在运行时加载 DLL 并使用指向其在内存中位置的指针调用函数,而不是使用 PInvoke 静态导入 API 调用。可以从内存中调用任意非托管代码(同时传递参数),从而以各种方式绕过 API 挂钩并反射性地执行利用后的有效负载。这也避免了通过 .NET 程序集的 PE 标头中的导入地址表查找可疑 API 调用的导入的检测。
classSolution { public: intstrStr(string haystack, string needle){ int n = haystack.size(); int m = needle.size(); for(int i = 0; i <= n - m; i++){ int j = i, k = 0; while(k < m && haystack[j] == needle[k]){ j++; k++; } if(k == m) return i; } return-1;
classSolution { public: string reverseWords(string s){ reverse(s.begin(), s.end()); int n = s.size(); int m = 0; for (int i = 0; i < n; ++i) { //如果是i++会导致字符重复,比如“ hello world ”到这一步会变成“worldw olleh” if (s[i] != ' ') { if (m != 0)s[m++] = ' '; int j = i; while (j < n && s[j] != ' ') s[m++] = s[j++]; reverse(s.begin() + m - (j - i), s.begin() + m); i = j; }
} s.erase(s.begin() + m, s.end());//调试发现这一步非常重要 return s; } };
classSolution { public: string replaceSpace(string s){ int num = 0; for(int i = 0; i < s.size(); i++){ if(s[i] == ' ') num++; } int left = s.size() - 1; s.resize(s.size() + num*2); int newSize = s.size(); int right = newSize - 1; for(; left < right; left--, right--){ if(s[left] != ' ')s[right] = s[left]; else{ s[right] = '0'; s[right-1] = '2'; s[right-2] = '%'; right -= 2; }
} return s; } };
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
classSolution: defreplaceSpace(self, s: str) -> str: num = s.count(' ') res = list(s) res.extend([' '] * num * 2)
left, right = len(s) - 1, len(res) - 1
while left >= 0: if res[left] != ' ': res[right] = res[left] right -= 1 else: res[right - 2 : right + 1] = '%20' right -= 3 left -= 1 return''.join(res)