【发布时间】:2014-01-13 00:54:31
【问题描述】:
我正在用 Ada 语言编写一个程序,该程序创建一个 WEP 密钥字典以用于渗透测试。这是代码:
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure CreateWepDict is
type IntegerTab is array (1..29) of integer;
-- Initializes the password
procedure PasswdInit (Passwd : in out IntegerTab; LgPasswd : in Integer) is
begin
for i in 1..LgPasswd loop
Passwd(i) := 0;
end loop;
end PasswdInit;
-- Writes the current password into the dictionary file
procedure WriteWepDict (PasswdInt : in IntegerTab; LgPasswd : in Integer) is
PasswdDict : File_Type;
PasswdStr : String(1..29);
begin
if not Is_Open(PasswdDict) then
open(PasswdDict,Append_File,"WepDict.txt");
end if;
for i in 1..LgPasswd loop
case PasswdInt(i) is
when 1 => PasswdStr(i) := '0';
when 2 => PasswdStr(i) := '1';
when 3 => PasswdStr(i) := '2';
when 4 => PasswdStr(i) := '3';
when 5 => PasswdStr(i) := '4';
when 6 => PasswdStr(i) := '5';
when 7 => PasswdStr(i) := '6';
when 8 => PasswdStr(i) := '7';
when 9 => PasswdStr(i) := '8';
when 10 => PasswdStr(i) := '9';
when 11 => PasswdStr(i) := 'A';
when 12 => PasswdStr(i) := 'B';
when 13 => PasswdStr(i) := 'C';
when 14 => PasswdStr(i) := 'D';
when 15 => PasswdStr(i) := 'E';
when 16 => PasswdStr(i) := 'F';
when others => pragma assert(false);
end case;
end loop;
New_Line(PasswdDict);
close(PasswdDict);
end WriteWepDict;
PasswdDict : File_Type;
LgPasswd : Integer := 5;
PassCur : Integer := 1;
Passwd : IntegerTab;
begin
-- Creates the dictionary file
create(PasswdDict,Append_File,"WepDict.txt");
PasswdInit(Passwd,LgPasswd);
while LgPasswd <= 29 loop
if PassCur /= LgPasswd then
PassCur := PassCur + 1;
else
if Passwd(PassCur) /= 16 then
Passwd(PassCur) := Passwd(PassCur) + 1;
else
Passwd(PassCur) := 1;
if PassCur /= 1 then
PassCur := PassCur - 1;
else
LgPasswd := LgPasswd + 1;
PasswdInit(Passwd,LgPasswd);
end if;
end if;
end if;
WriteWepDict(Passwd,LgPasswd);
end loop;
end CreateWepDict;
我在 WriteWepDict 子过程的“结束情况”处出现“预期语句”错误。你能告诉我为什么吗?
编辑:我根据Brian的修改重写了程序,但是现在还有一个问题:创建的文件是空的!
【问题讨论】:
-
您似乎声明了两次
PasswdDict : File_Type;;也许一个隐藏另一个?请注意,如果您在本地过程 WriteWepDict 之前声明它,它将对该过程可见(如果您还删除了 WriteWepDict 中的第二个声明) -
如果您希望我们帮助找出重写程序的问题所在,也许您应该发布重写程序?在原来的程序中,你费尽心思设置
PasswdStr,但你什么也没做。新代码也是这种情况吗?你忘记Put_Line了吗? -
是的,最好恢复这个问题的标题并用新代码提出一个新问题......
-
去他妈的! @ajb 你说得对:我忘记了 WriteWepDict 中的 Put_Line !!!我的头在云端!!!!!!