Compilation of Cygwin and Vulnerability Attack Programs
Baishi http://baishi.8561.net
One. Cygwin
The free software Cygwin under Microsoft Window is a free software developed by Red Hat, which is a UNIX analog environment running on a Windows platform. It is a full-featured Win32 application, which is a porting for UNIX applications. Layers, it is fully compatible with Win32 (including Windows 95/98 / NT currently used). The software project launched in 1995, the main purpose is to transplant the GNU development tool to the Win32 system.
Cygnus first improved the development tools such as GCC, GDB, GAS, enabling them to generate and explain the Win32 target file. Then they want to transplant these tools to the Windows platform. One solution is based on Win32 API's source code for these tools, which clearly requires a lot of work. Therefore, they have taken a different way - they wrote a shared library (that is, cygwin.dll), encapsulate unix style in the Win32 API (such as Fork, Spawn, Signals, SELECT, SOCKETS, etc.) Inside, that is, they wrote an analog layer of a UNIX system library based on Win32 API. This way, just connect these tools and this shared library together, you can use the cross-compiler on the UNIX host to generate a toolset that can run on the Windows platform. Based on these development tools on the Windows platform, Cygnus gradually puts other tools (almost no need to modify the source code, just modifying their configuration scripts) software transplanted to Windows. This way, running Bash and development tools on the Windows platform, user tools, feel like working on UNIX. The C compiler under the Windows platform is based on GCC, which is completely compatible with Window unique things, such as support for Winsock.
Cygwin includes package: 1. Development kit: Binutils, Bison, ByAcc, Dejagnu, DIFF, EXPECT, FLEX, GAS, GCC, GDB, ITCL, LD, Libstdc , Make, Patch, TCL, TIX, TK, etc .; 2. UNIX Tools: ASH, BASH, BZIP2, DIFF, FileUtils, FindUtils, Gawk, GREP, GZIP, LESS, M4, SED, ShellUtils, Tar, TextUtils, Time; 3. Source of package.
There are several uses for Cygwin
1. Learn a UNIX / Linux operating environment, work in a similar UNIX environment, use common UNIX Utilities (can be Bash Shell, or in standard Win32 Command shell), this is undoubted to use the Unix system administrator who must use Windows. relief. In this regard, its largest opponent is Microsoft's less free SFU (Windows Services for UNIX) http://download/a/1/C/A1CA7AF1-A6E3-46E7-874A-4C5D8C0FB3B7 /Sfu35sel_en.exe.
2. Transplant from UNIX to Windows without having to make significant changes. Just as the standard build program in UNIX, you can use the Source to configure and make. (For example, using Cygwin OpenSSH Pure-FTP alternative Server-U, Server-U runs dozens of vulnerabilities in the past year - Khan http://blog.muduo.net/blog.php?job=art&articleid=a_20041201_131804. Of course, Do not necessarily have the role of reinforcement. Apache has no only a platform that does not only have a UNIX operating system and other derivative platforms, only for platforms such as NetWare network operating systems such as Windows, OS2 and Novells. Cygwin users' vulnerabilities.) 3. Some special development work.
Especially useful to use the GNU toolset to perform embedded system development on Windows. As embedded systems are developing in China, more and more developers have interested in Cygwin.
4. Other applications. (For example, build a honeypot http://demonalex.nease.net/cygwin/index.html)
two. Compilation of vulnerability attack programs
In fact, this is also the second use of Cygwin, which is previously mentioned. For the C / C code written under UNIX, we need to compile the C compiler under UNIX. (Since the code write environment and the CPU of the local environment may be different, the CPU instruction set is different, the compilation environment of the two is different, and some code directly related to hardware needs to be compiled with a specific CPU architecture. Implementation. In addition, many WIN32 and UNIX code, such as service and daemon, messages, and model numbers, these are the mechanisms determined by the system characteristics, and cannot be transplanted by simple source code. So, these source code can only be used GNU's GCC compilation tools to compile, link, and cannot be compiled with compiler under WIN.)
Of course, you can virtualize a computer, fully install the Linux system, to achieve UNIX development environments. This, Windows has, Linux is also available. However, this type of virtual machine system is highly required by physical hardware, and such a system compiled and developing procedures is the native code of parasitic systems, and the host system is impossible to execute, and the reverse compatibility has become a problem. Popular speaking, parasitic system-virtual Linux compiled program is impossible to execute under host system - WIN.
You can also use the GCC of Windows MingW and Microsoft to share data between Windows and UNIX computers, securely trusted SFU (which provides Interix SDK, which contains multiple tools for generating applications, such as GCC). And G , also contains many header files and libraries such as libc, libcurses, and libx11) or Microsoft InterIX (InterIx Subsystems have been integrated with Services for UNIX). (I haven't used Mingw and SFU, I will try it, I welcome interested friends to exchange learning.)
To compile the program that can be directly executed under WIN, the most simple and effective way to apply the most simple and effective way to compile C / C code written under UNIX, whose easy-to-use and validity is Windows in all GNU development tools. The version is clear (because Red Hat continuously develops Cygwin's main purpose is to transplant the GNU development tool of the Free Software to Win32 system is designed for program developers, which provides under Windows operating system. A UNIX development environment is used to help program developers transplant the application from UNIX / Linux to the Windows platform, of course, Unix Linux code for easy porting in the Windows platform is a powerful toolset.) It can be in WWW . cygwin.com Download and installation, there are many related articles on Cygwin. Mainly to talk about the installation of the package (嘿, this is also a pull-down), because by default, the Cygwin base package will not install the GCC, so the default setting must be modified.
Move the mouse to the plus ( ) of the Devel side, then click on it to expand the DEVEL class.
Figure 1 Select the package for installation
It will be seen that there are many entrances under Devel, only three are what you need, the order is as follows:
Binutils
2. GCC
3. GCC-MINGW
Not all default basic packages need to run GCC, but they are not too big, so install them simplified, install them.
Note It is easy to select the wrong package or version, especially when reinstall, because the loop button in the selection window is not standard. In this step we recommend more care, especially if there are multiple GCC versions.
To select these three packages, click on each two-way arrow in the column New until the version number of each package is displayed. According to the appropriate version of the installed and mirror, the inlet is included in each icon:
If there are multiple versions available, select the maximum number of numbers. To download the binary, make sure the "bin" column is selected. (Of course, you can simply double click "All" to change the default to install, "All Install the DEVEL class")
After installation, there will be Cygwin icons on the desktop. Click to enter the environmental interface. First, enter the GCC, if the "GCC No Input Files" is displayed, the installation is successful. Enter "GCC -o Files.exe Files.c" entered "GCC -o Files.exe Files.c" under the Cygwin Shell, the source code file that you want to compile. " This creates an exe file in the home directory. This file is to run directly in WIN needs to put the CygWin1.dll dynamic connection library file and the compiled executor in the same directory, Cygwin1.dll file can be under Cygwin Located in the bin directory.
-------------------------------------------------- - I use Cygwin as the familiar process of myself under the window, I will continue, go to UNIX. . . It is very interesting.
-------------------------------------------------- -
Attachment: Introduction to the GCC Compiler. Typically followed by some options and file names using the GCC compiler. The basic usage of the GCC command is as follows: GCC [options] [filenames] option Specifies how the compiler is compiled. The GCC option GCC has 100 compilation options. Many of these options may never be used, but some major options will always encounter. Many GCC options include more than one character, so you must specify your respective hyphens for each option. For example, the two of the following commands are different: gcc -p -g test.c gcc -pg test.c The first command tells the GCC to establish an analysis (PROF command) when compiling Test.c and add debugging information. Go to the executable file. The second command only tells the GCC to establish a profiling information for the gprof command. When there is no option, GCC generates an executable named A.out. Use the -o compilation option to name it with the specified file name with the executable file. For example, compiling a C pro program called Count.c into an executable called count, you should enter the command: gcc -o count count.c -c option tells GCC to compile the source code as a target code. The target code file established by the GCC has a .o extension. The -s compilation option tells GCC to stop compiling after the assembly language file is generated for C code. The default extension of the assembly language file generated by the GCC is .S. The -e option indicates that the compiler is only preprocessing the input file. When this option is used, the output of the preprocessor is sent to the standard output instead of being stored in the file. When using the GCC to compile C code, it will try to complete compilation with the least amount of time and make the compiled code easy to debug. Easy to debug means that the compiled code has not been optimized. If necessary, you need to allow the compiler to optimize the code. The -o option tells the GCC to optimize the source code. These optimizations will make the program faster in most cases. -O2 option tells GCC to generate as small and as fast as possible. -O2 option will make compiled speeds slower than using -O, but the usual code execution speed will be faster. GCC supports several commissioning and profiling options, often -g and -pg. The -g option tells the GCC to generate debugging information that can be used by the GNU debugger to debug your program. GCC provides a lot of features in many other C compilers that you can use in the GCC you can use. The -pg option tells GCC to add additional code in the compiled program. When running the program, generate the profiling information for Gprof to display the time consumption of your program. reference:
Compile DB2 UDB stored procedures with GCC in Windows
Http://www-900.ibm.com/developerWorks/cn/dmdd/library/techarticles/0306haungs/0306haungs.shtml