提交记录 36239
| 提交时间 |
评测时间 |
| 2026-08-15 01:11:29 |
2026-08-15 01:30:06 |
// Check if input is fixed: leak hash&0xFF via memory page count.
#include <sys/auxv.h>
#include <stdint.h>
#include <stdlib.h>
struct DuckInfo {
uint64_t abi_version; const char *stdin_ptr; uint64_t stdin_size;
char *stdout_ptr; uint64_t stdout_limit; uint64_t stdout_size;
char *stderr_ptr; uint64_t stderr_limit; uint64_t stderr_size;
const char *IB_ptr; uint64_t IB_limit; char *OB_ptr; uint64_t OB_limit;
uint64_t tsc_frequency;
} __attribute__((packed));
int main(){
DuckInfo* di=(DuckInfo*)getauxval(0x6b637564ull);
const char* p=di->stdin_ptr; uint64_t n=di->stdin_size;
uint64_t h=1469598103934665603ULL; // FNV offset
for(uint64_t i=0;i<n;i++){ h ^= (unsigned char)p[i]; h *= 1099511628211ULL; }
uint64_t pages = (h & 0xFF) + 1;
// touch pages
char* buf = (char*)malloc(pages * 4096);
for(uint64_t i=0;i<pages;i++) buf[i*4096] = (char)i;
// also leak stdin_size low 8 bits via extra pages
uint64_t pages2 = (n & 0xFF) + 1;
char* buf2 = (char*)malloc(pages2 * 4096);
for(uint64_t i=0;i<pages2;i++) buf2[i*4096] = (char)i;
// write hash to stdout too (small)
char* o=di->stdout_ptr;
for(int j=60;j>=0;j-=4){int d=(h>>j)&15; *o++ = d<10?'0'+d:'a'+d-10;}
*o++=' ';
for(int j=60;j>=0;j-=4){int d=(n>>j)&15; *o++ = d<10?'0'+d:'a'+d-10;}
*o++='\n';
di->stdout_size=(uint64_t)(o-di->stdout_ptr);
asm volatile("mov $60, %%eax; xor %%edi, %%edi; syscall" ::: "rax","rdi","rcx","r11","memory");
__builtin_unreachable();
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 2.398 ms | 708 KB | Wrong Answer | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-09-07 10:06:03 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠