zoukankan      html  css  js  c++  java
  • File Tamper 1.0

    main.cpp

     1 #include <iostream>
     2 #include <fstream>
     3 #include <stdlib.h>
     4 
     5 using namespace std;
     6 
     7 int main ( int argc, char* argv[] ) {
     8     if ( argc != 4 ) {
     9         cout << "Usage: ft <File> <Off> <Data>" << endl;
    10         return -1;
    11     }
    12     fstream file ( argv[1], ios::in | ios::out | ios::binary | ios::ate );
    13     if ( file.is_open() ) {
    14         long long fileSize = static_cast<long long> ( file.tellg() );
    15         cout << "Size: " << fileSize << " bytes" << endl;
    16         long int yPos = strtol ( argv[2], NULL, 16 );
    17         long int yData = strtol ( argv[3], NULL, 16 );
    18         unsigned char sData = static_cast<unsigned char> ( yData );
    19         if ( yPos < 0 || yPos >= fileSize ) {
    20             cout << "Overflow. [0 ~ " << fileSize - 1 << "]" << endl;
    21             return -1;
    22         }
    23         std::ios_base::seekdir sPos = static_cast<std::ios_base::seekdir> ( yPos );
    24         file.seekg ( sPos );
    25         char cbit[8];
    26         itoa ( file.get(), cbit, 16 );
    27         cout << "Data: " << cbit << endl;
    28         file.seekg ( sPos );
    29         file << sData;
    30         file.close();
    31         cout << "Tampering successfully." << endl;
    32         return 0;
    33     } else {
    34         cout << "Can not open file." << endl;
    35         return -1;
    36     }
    37 }

    附件1

  • 相关阅读:
    Django 中间件
    Django之ORM介绍
    ORM相关操作
    Django Form表单
    Django REST framework 中文文档
    前端基础之BOM和DOM
    Django--ORM(2)
    Django--视图
    Django--路由系统
    Django--模板语言
  • 原文地址:https://www.cnblogs.com/rms365/p/10864269.html
Copyright © 2011-2022 走看看