Notice
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- javascript
- malware
- idapython
- open office xml
- Ransomware
- Python
- svn update
- Injection
- h5py.File
- hex-rays
- NumPy Unicode Error
- Rat
- data distribution
- ida
- error fix
- MySQL
- commandline
- 포인터 매핑
- ida pro
- TensorFlow
- x64
- error
- ecma
- pytest
- idapro
- idb2pat
- why error
- debugging
- Analysis
- mock.patch
Archives
- Today
- Total
13 Security Lab
[C] 파일 크기 구하기 본문
소켓통신중 패킷의 헤더에 데이터 파일의 전체 길이를 담기위해 파일 크기를 구하는 방법을 찾게되었다
stat함수 이용
파일포인터의이동#include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <errno.h> int main() { struct stat buf; int ret; ret = stat("test.c", &buf); if ( ret != 0 ) { perror("stat()"); exit(errno); } printf("len = %ld\n", buf.st_size); return 0; }
#include <stdio.h>
int main()
{
FILE *fp;
fp = fopen("test.c", "rb");
fseek(fp, 0L, SEEK_END);
printf("%ld \n", ftell(fp));
fclose(fp);
return 0;
}
//fopen시 바이너리 모드로 열어야함, (unix에서는 기본setting이 바이너리모드로 열리는것)
ifstream fin("myFile", ios_base::in | ios_base::binary);
fin.seekg(0, ios_base::end);
istream::pos_type pt = fin.tellg();
Comments