__ac_signature
时间: 2023-05-08 07:01:56 浏览: 97
__ac_signature是Plone CMS中的一个安全特性。它是用来防止CSRF(Cross-site request forgery)攻击的。CSRF是一种网络攻击方式,攻击者利用用户已登录的身份发送恶意请求,使得用户在其不知情的情况下,执行改变数据、转账等恶意操作。为了防止这种攻击,Plone CMS使用了__ac_signature。
在用户登录时,Plone CMS会生成一个私有密钥(这个密钥只有服务器端知道),同时也会将用户名、密码等信息生成一个字符串,并用私有密钥进行加密,形成__ac_signature。在用户发起请求时,系统会自动解密__ac_signature,然后比对加密前后的字符串。如果两者相同,则表明该请求并非恶意攻击。
__ac_signature是Plone CMS中的一项核心特性,保证了系统的安全性,可以有效地预防CSRF攻击。
相关问题
头信息示例如下vbf_version = 2.6; header { sw_part_number = "8895913857"; sw_version = "B"; sw_part_type = DATA; data_format_identifier = 0x00; ecu_address = 0x1012; erase = { { 0x00B60000, 0x00010000 }, { 0x40200300, 0x00000D00 } }; verification_block_start = 0x40200300; verification_block_length = 0x0000002C; verification_block_root_hash = 0x3AB70E8A9C521B370E37D6FF03263770426297167C495C80C8AF3EA0B9AC3C7C; file_checksum = 0xEDB03AFF; sw_signature_dev = 0x7B3E3A02DBBC87DCC7BB9BFD795C7D1355C82DCA947BA5225B5BC549F4FF1648C3DC78C7947DF7F751A856351FBF340CB9F9E5B0790F026DC080800EA8A7AE6383DF63A0C8447ADB921A29A6FD2B84BA83D4769301FDBD3B019442A8FC588864F299D546587019E7700C345899F4CBEA7E5F831132DDC563C589DDD64F5A842129B803BC4C324310918162BC01E6312374A370A39F201F425B4DB457F8BA829A459BD5ED9E1673D9BD923D5E1287AAB45AC3B8999FC96CA514CB5EFBEBD5B23FDBF8AC944C376F44153B2C7F3B415AB87D274A4BD2DD120B70DA67721062F03125FA9D162C10855CD4F59A43253D0421A8D7AE851188E9D0EB1BAB13DE308012; sw_signature = 0x422CB67A399E4C7E0AA3621C8B9DA49947E5E655E83D0181A76CFA8FEFD250E0615576E3907530A4263F3198B8080ACE74E5113987EFA419B88B409D794860FD4A65511B2C95B1716947C6B7BE335800D8231C327AB866B7CA4D4F9CCB06BEEBDBA5EB797E21FC419B7D608D68FDD9F8095603ED298991DB8AC836D023B2059BF3641D6BADC4F626F5DC201561726FE9FB58BB4AEA0A04B0D9FE3B05C072AAA0CFE711679635187062FDB1AED7309E3D4F3400D1A4254884832CDB20C2C7DA0E264EF7F622DC0042C94AB19D7C74C966999A2A6D0F4C43EE179FFB6743FD056113898DFD1FF3E5E0DDE3B7010381857F046CCAD27357F39403FA2776821C438F; }, 请用c写代码 把头信息都解析出来
以下是用C语言解析头信息的示例代码:
```c
#include <stdio.h>
#include <stdint.h>
#define MAX_ERASE_REGIONS 10
typedef struct {
uint32_t start_address;
uint32_t length;
} erase_region_t;
typedef struct {
char sw_part_number[32];
char sw_version;
char sw_part_type[8];
uint8_t data_format_identifier;
uint16_t ecu_address;
erase_region_t erase_regions[MAX_ERASE_REGIONS];
uint32_t verification_block_start;
uint32_t verification_block_length;
uint8_t verification_block_root_hash[32];
uint32_t file_checksum;
uint8_t sw_signature_dev[128];
uint8_t sw_signature[128];
} header_t;
int main() {
// 头信息示例字符串
char header_str[] = "vbf_version = 2.6; header { sw_part_number = \"8895913857\"; sw_version = \"B\"; sw_part_type = DATA; data_format_identifier = 0x00; ecu_address = 0x1012; erase = { { 0x00B60000, 0x00010000 }, { 0x40200300, 0x00000D00 } }; verification_block_start = 0x40200300; verification_block_length = 0x0000002C; verification_block_root_hash = 0x3AB70E8A9C521B370E37D6FF03263770426297167C495C80C8AF3EA0B9AC3C7C; file_checksum = 0xEDB03AFF; sw_signature_dev = 0x7B3E3A02DBBC87DCC7BB9BFD795C7D1355C82DCA947BA5225B5BC549F4FF1648C3DC78C7947DF7F751A856351FBF340CB9F9E5B0790F026DC080800EA8A7AE6383DF63A0C8447ADB921A29A6FD2B84BA83D4769301FDBD3B019442A8FC588864F299D546587019E7700C345899F4CBEA7E5F831132DDC563C589DDD64F5A842129B803BC4C324310918162BC01E6312374A370A39F201F425B4DB457F8BA829A459BD5ED9E1673D9BD923D5E1287AAB45AC3B8999FC96CA514CB5EFBEBD5B23FDBF8AC944C376F44153B2C7F3B415AB87D274A4BD2DD120B70DA67721062F03125FA9D162C10855CD4F59A43253D0421A8D7AE851188E9D0EB1BAB13DE308012; sw_signature = 0x422CB67A399E4C7E0AA3621C8B9DA49947E5E655E83D0181A76CFA8FEFD250E0615576E3907530A4263F3198B8080ACE74E5113987EFA419B88B409D794860FD4A65511B2C95B1716947C6B7BE335800D8231C327AB866B7CA4D4F9CCB06BEEBDBA5EB797E21FC419B7D608D68FDD9F8095603ED298991DB8AC836D023B2059BF3641D6BADC4F626F5DC201561726FE9FB58BB4AEA0A04B0D9FE3B05C072AAA0CFE711679635187062FDB1AED7309E3D4F3400D1A4254884832CDB20C2C7DA0E264EF7F622DC0042C94AB19D7C74C966999A2A6D0F4C43EE179FFB6743FD056113898DFD1FF3E5E0DDE3B7010381857F046CCAD27357F39403FA2776821C438F; }";
// 将头信息解析到结构体中
header_t header = {0};
sscanf(header_str, "vbf_version = %*f; header { sw_part_number = \"%[^\"]\"; sw_version = \"%c\"; sw_part_type = %s; data_format_identifier = %hhx; ecu_address = %hx; erase = { %*[{ ]{ 0x%x , 0x%x }%*[ }],%*[{ ]{ 0x%x , 0x%x }%*[ }] }; verification_block_start = %x; verification_block_length = %x; verification_block_root_hash = 0x%32hhx; file_checksum = 0x%x; sw_signature_dev = 0x%256hhx; sw_signature = 0x%256hhx; }",
header.sw_part_number,
&header.sw_version,
header.sw_part_type,
&header.data_format_identifier,
&header.ecu_address,
&header.erase_regions[0].start_address,
&header.erase_regions[0].length,
&header.erase_regions[1].start_address,
&header.erase_regions[1].length,
&header.verification_block_start,
&header.verification_block_length,
header.verification_block_root_hash,
&header.file_checksum,
header.sw_signature_dev,
header.sw_signature);
// 输出解析结果
printf("sw_part_number = %s\n", header.sw_part_number);
printf("sw_version = %c\n", header.sw_version);
printf("sw_part_type = %s\n", header.sw_part_type);
printf("data_format_identifier = 0x%02x\n", header.data_format_identifier);
printf("ecu_address = 0x%04x\n", header.ecu_address);
printf("erase_regions:\n");
for (int i = 0; i < MAX_ERASE_REGIONS; i++) {
if (header.erase_regions[i].length == 0) {
break;
}
printf(" [%d] start_address = 0x%08x, length = 0x%08x\n", i, header.erase_regions[i].start_address, header.erase_regions[i].length);
}
printf("verification_block_start = 0x%08x\n", header.verification_block_start);
printf("verification_block_length = 0x%08x\n", header.verification_block_length);
printf("verification_block_root_hash = ");
for (int i = 0; i < 32; i++) {
printf("%02x", header.verification_block_root_hash[i]);
}
printf("\n");
printf("file_checksum = 0x%08x\n", header.file_checksum);
printf("sw_signature_dev = ");
for (int i = 0; i < 128; i++) {
printf("%02x", header.sw_signature_dev[i]);
}
printf("\n");
printf("sw_signature = ");
for (int i = 0; i < 128; i++) {
printf("%02x", header.sw_signature[i]);
}
printf("\n");
return 0;
}
```
该代码将头信息解析到一个结构体中,然后逐一输出解析结果。注意,该代码仅适用于给定的头信息示例字符串,如果头信息的格式有所变化,可能需要相应地修改代码。
用python写一个函数读取二进制文件,二进制文件第一行是版本信息 等号左边是描述,右边是值 后面的头信息以{开始,最后一个}结束 注意头信息里面也有{} 头信息里面的参数都是等号左边是描述,右边是值,值的最后以;结束 头信息的参数可多可少 下面是文件头信息示例 vbf_version = 2.6; header { // Created by VbfSign build: 2017/12/12 on 2020/10/19 9:54 sw_part_number = "8891903679"; sw_version = "A"; sw_part_type = SBL; data_format_identifier = 0x10; ecu_address = 0x1A31; file_checksum = 0x0D81F89D; call = 0x1FFF8004; verification_block_start = 0x20000800; verification_block_length = 0x00000054; verification_block_root_hash = 0x3C440B332BE20F05B9C108F347658FBEBEAA4B3E0D655CAEE76AE210E93E828A; sw_signature_dev = 0x8A97CF400B82AB1B0D82C26976CB26F7AE6B34A87E56675D39E52B9C811F1AB9C040B52FA925BB60E981F388A748F0E09B20D2CBEF7A9A49119EC68C1EFE83BD0EA34B0FDE59F16B8533FEE72219D698C898F4D9EB40B9FCE42C73C028519D1767C11AEEBF0FE746B2F8AB601DA7E3686E4B46AC05851FCDD7A55CBF5F72DA826B0152640514F87CE905362CBFA7F19FE04CAA84A2882E20592E2000D576F629A1B05A207FB59DDC6E8DD10154F148AACA7CBBD5E978BF9E67EDC1ADD186E098A81FEF3C657D2AEFC083F25D307DE00715AB8B2C78CDB23CD13B3DAD9110333ADAB672F1EC6B6D5CFCAF04FC71490A54ECE1745E46D4AB3A9D1E0BA0CACE0B92; sw_signature = 0x12FBA8C1BCB608E5ADC31E1AC73292E5EB7DE42813F6F403DE17A1436766A43BBB78387019BBAF910B86F98214278093889EBB8E9CCC24C4A659F6C5FA3C9F1B794C88544C36235739686474454253AFD99020193B86EBD6FB6CD190B723ECF73CAA3C35F65C82A9E0BEFC94711FBBAD428DD77276B2933508A086720B934EA0691A49D0510C1F107448BCF3FA9378057628280A0E49FE3F196F925E31D1234ECF759911F05274DC6291FF5AFF2EF6CB7039062314559F799D1CB5E82902D10B20755E45F23F397EA335098A8E87002D681D8A400E4AC56CEBC9E2BBA9023B311361A5432A321CB588C1BF691898DA6486A3088E5AD93A3A1DB99461E5A75825; }
可以使用Python的with语句和正则表达式来读取该二进制文件,并将头信息存储为字典:
```python
import re
def read_binary_file(filename):
header_regex = re.compile(r'(\w+)\s*=\s*(.*?)(?=;|\})', re.DOTALL)
header = {}
with open(filename, 'rb') as f:
line = f.readline().decode().strip()
version_info = line.split('=')[1].strip()
for match in header_regex.finditer(f.read().decode()):
header[match.group(1)] = match.group(2).strip()
return version_info, header
```
函数中,首先定义了一个正则表达式,用于匹配头信息中的参数。然后使用Python的with语句打开文件,并读取文件的第一行版本信息。接着使用正则表达式匹配头信息,并将匹配结果存储为字典。最后返回版本信息和头信息字典。
注意,由于头信息可能包含大括号,因此使用了re.DOTALL标志来匹配任意字符,包括换行符。
阅读全文