0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CpawCTF Q20.[Crypto]Block Cipher

Posted at

CpawCTF Q20.[Crypto]Block Cipher

問題から以下を読み込みます。読みやすいように一部書き換えました。

problem.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char* argv[]) {
	int i;
	int j;
	int key = atoi(argv[2]); //文字列を整数に変換
	const char* flag = argv[1]; //文字列
	printf("cpaw{");
	for (i = key - 1; i <= strlen(flag); i += key) {  //keyの値だけ文字列をスキップしながら文字列をループ
		for (j = i; j >= i - key + 1; j--) { //keyの値だけ戻りながら文字列を逆順にループ
			printf("%c", flag[j]);
		}
	}
	printf("}");
	return 0;
}

開発者用コマンドプロンプトでcrypto.cのあるディレクトリがあるフォルダに移動して

comand.tr
$cl
使い方: cl [オプション...] ファイル名... [ /link リンク オプション...] //これが出てきたらあっています
$crypto ruoYced_ehpigniriks_i_llrg_stae 4 
//argv[1]:ruoYced_ehpigniriks_i_llrg_stae, argv[2]:4
cpaw{Your_deciphering_skill_is_graeat}

答えがわかりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?