DIY Trojan programming Text Speech

Source: Internet
Author: User
Tags htons

Trojan programming DIY text voice cold wind Dezhou Science and Technology Vocational College in the black anti-DDoS 2nd Tianya decline (is the boss of the Computer newspaper hacker camp, huh, huh) I introduced the remote control program of "shoushu". One of the features is that "speaking English with the other party" is very interesting. I tried to make a discovery by myself, the program shown in result 1 is written in vc6.0 + Win2000 into two files: the server (SDK) and the client. After running the server on other machines, you can "speak" it through the client, if the target address is blank, it will be read on your computer. The reading function of Text Speech shoushu is implemented through text speech. Text Speech is also called TTS (text-to-speech). It is used to convert text into speech, if we want to develop such a program, we need to use the soft-provided software development kit Microsoft Speech SDK. Currently, the most widely used version is 5.1. The package size is around MB in the sky, junhuadu can be downloaded. It contains detailed development materials and executable programs, as shown in figure 3, we can easily develop our own programs by referring to the examples provided in the help document. Before you begin, install the Microsoft Speech SDK. After installation, go to the installation directory and copy the header files and library files in the include and Lib directories to the Development Directory of VC. Here is C: /Microsoft Visual Studio/vc98/include and Lib directories. Of course, you can also set the path in VC (I like to copy it directly) now you can write the program. The server has been listening on port 5555 since it was run on the server. After receiving the data, the Code is as follows # include <SAPI. h> // header file required by TTS
# Include <windows. h>
# Include <Winsock. h>
# Pragma comment (Lib, "ws2_32") // load the Library Function
 
Const int buffer_len= 2048;
 
Int apientry winmain (hinstance,
Hinstance hprevinstance,
Lpstr lpcmdline,
Int ncmdshow)
{
 
Wsadata;
Socket server;
Socket Client;
Sockaddr_in serveraddr;
Sockaddr_in clientaddr;
Int Port = 5555;
Char buffer [buffer_len];
Wchar wbuffer [buffer_len];
 
Memset (wbuffer, 0, sizeof (wchar) * buffer_len );
Memset (buffer, 0, sizeof (char) * buffer_len );
 
 
Word ver = makeword (2, 2); // judge the Winsock version
Wsastartup (ver, & wsadata); // initial socket
 
Server = socket (af_inet, sock_stream, ipproto_tcp );
 
Serveraddr. sin_family = af_inet;
Serveraddr. sin_port = htons (port );
Serveraddr. sin_addr.s_un.s_addr = htonl (inaddr_any );
 
BIND (server, (sockaddr *) & serveraddr, sizeof (serveraddr ));

Listen (server, 5 );
 
Int Len = sizeof (clientaddr );
 
While (1) // accepts connections cyclically
{
Client = accept (server, (sockaddr *) & clientaddr, & Len );
 
While (1) // cyclically accept data
{
If (Recv (client, buffer, buffer_len, 0 )! = 0) // play if data exists
{
Memset (wbuffer, 0, sizeof (wchar) * buffer_len );
// Must be converted to a wide character first
Multibytetowidechar (cp_acp,
Mb_precomposed, // character-type options
Buffer, // address of string to map
Buffer_len, // number of bytes in string
Wbuffer, // address of Wide-Character Buffer
Buffer_len // size of Buffer
);
 

Memset (buffer, 0, sizeof (char) * buffer_len );

Ispvoice * pvoice = NULL;
 
If (failed (coinitialize (null) // initialize the COM interface
 
{
MessageBox (null, "error", "error to intiliaze com", 0 );
}
// Obtain the ispvoice Interface
Hresult hR = cocreateinstance (clsid_spvoice, null, clsctx_all, iid_ispvoice, (void **) & pvoice );
 
If (succeeded (HR ))
{
HR = pvoice-> speak (wbuffer, 0, null); // start reading
Pvoice-> release (); // release the sound object after completion
Pvoice = NULL;
}
 
Couninitialize (); // release
}
Else
Break; // accept data as 0 and exit
}
}
 
Closesocket (server );
Closesocket (client );
Wsacleanup ();
 
Return 0;
}

 

The implementation code is quite simple. It should be noted that in pvoice-> speak (const wchar * pwcs, DWORD dwflags, ulong * pulstreamnumber ); pwcs is of the wchar type, that is, Unicode encoding. Therefore, Unicode conversion is required after data is received from the network. The encoding conversion can be implemented using the multibytetowidechar API, this is an easy-to-use API. You can use the above Code. The implementation of the client on the client is also very simple, so I will not waste my feelings. Haha void cmydlg: onok ()
...{
Updatedata ();
 
If (m_addr.isempty () // if the address is null, the local video is played.
...{
// The implementation code is almost the same as the server
}
Else // send data to the target
...{
Wsadata;
Socket Client;
Sockaddr_in serveraddr;
Int Port = 5555;
 
Word ver = makeword (2, 2); // judge the Winsock version
Wsastartup (ver, & wsadata); // initial socket
 
Client = socket (af_inet, sock_stream, ipproto_tcp );
 
Serveraddr. sin_family = af_inet;
Serveraddr. sin_port = htons (port );
Serveraddr. sin_addr.s_un.s_addr = inet_addr (m_addr.lockbuffer (); // m_addr is a text control that accepts an address.
 
Connect (client, (sockaddr *) & serveraddr, sizeof (serveraddr ));
 
Send (client, m_text.lockbuffer (), m_text.getlength (), 0); // m_text is the text control that accepts the content.
 
Closesocket (client );
Wsacleanup ();
}
}

 

If necessary, you can expand it to read Chinese and Japanese, but you have to download the voice patch ...... you can also specify a male or female voice to read aloud. However, I think female voice is better. This article provides a simple function, if you want to write a powerful program, refer to the help documentation of Microsoft Speech SDK,

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.