Building a Dynamic-Link Library using C++ MinGW Posted: 21 Jul 2013 03:19 AM PDT Dynamic-Link Library or DLL, is implementation of shared library concept in Microsoft Windows and OS/2 operating system. Usually it has file extension DLL. The file formats for DLL are the same as for executable file – that is Portable Executable (PE) for 32-bit and 64-bit Windows, and New Executable (NE) for 16-bit Windows. In this article, we will discuss about how we can create a .dll file using C++ and compiler MinGW. The Files We will use three files: my_dll.h, my_dll.cpp, and client.cpp The my_dll.h is a header file where we place declarations: // my_dll.h #ifndef _MY_OWN_DLL_H__ #define _MY_OWN_DLL_H__</pre> #ifdef __cplusplus extern "C" {
Programming Problem Set: 99 Problems Chapter 4 Posted: 20 Jul 2013 04:03 AM PDT Ninety-nine Problems is generalized version to famous P-99: Ninety-Nine Prolog Problems collection used for teaching programming. The problems initially set for prolog but later many solutions come from various programming language. The purpose of this problem is to give us opportunity to practice our skills in logic programming. The goal is to find the most elegant solution of the given problem. Efficiency is important, but logical clarity is even more crucial. The problem set are divided into seven categories / chapters: Lists, Arithmetic, Logic and Codes, Binary Trees, Multiway Trees, Graphs, and Miscellaneous. In this chapter you will be only given a problem set. The solution might come however it would be on different page. This chapter will cover about Binary Trees. Binary is either empty or it is composed of a root element and two successors, which are binary tree themselves. The problems in this chapter is a continuation of previous chapter, therefore the numbering will start from the last problem. For the sake of writing, we will denote tree node as t (value, left, right). 45. Check whether a given object / term is a binary tree. The predicate is succeeds if and only if its argument is a representing a binary tree. example: is_tree_p( t(a, t(b, null, null), null) -> true 46. Construct a completely balanced binary trees In a completely balanced binary tree, the following property holds for every node: The number of nodes in its left subtree and the number of nodes in its right subtree are almost equal, which means their difference is not greater than one. Write cbal_tree/2 to construct completely balanced binary trees for a given number of nodes. The predicate should generate all solutions via backtracking. Put the letter 'x' as information into all nodes of the tree. Example: cbal_tree_p( 4 ) -> t(x, t(x, null, null), t(x, null, t(x, null, null))) t(x, t(x, null, null), t(x, t(x, null, null), null)) ...etc 47. Symmetric binary trees. Let us call a binary tree symmetric if you can draw a vertical line through the root node and then the right subtree is the mirror image of the left subtree. Write symmetric/1 to check whether a given binary tree is symmetric. <b>Hint:</b> Write mirror/2 first to check whether one tree is the mirror image of another. We are only interested in the structure, not in the contents of the nodes. 48. Binary search trees (dictionaries) Write a predicate to construct a binary search tree from a list of integer numbers. Example: construct_p( [3,2,5,7,1] ). -> t(3, t(2, t(1, nil, nil), nil), t(5, nil, t(7, nil, nil))) 49. Generate and test paradigm. Apply the generate-and-test paradigm to construct all symmetric, completely balanced binary trees with a given number of nodes. Example: sym_cbal_trees_p( 5 ) -> [t(x, t(x, nil, t(x, nil, nil)), t(x, t(x, nil, nil), nil)), t(x, t(x, t(x, nil, nil), nil), t(x, nil, t(x, nil, nil)))] How many such trees are there with 57 nodes? Investigate about how many solutions there are for a given number of nodes. What if the number is even? Write the appropriate solution. 50. Construct height-balanced binary trees. In a height-balanced binary tree, the following property holds for every node: The height of its left subtree and the height of its right subtree are almost equal, which means their difference is not greater than one. Write a predicate hbal_tree/2 to construct height-balanced binary trees for a given height. The predicate should generate all solutions via backtracking. Put the letter 'x' as information into all nodes of the tree. Example: hbal_p( 3 ) -> t(x, t(x, t(x, nil, nil), t(x, nil, nil)), t(x, t(x, nil, nil), t(x, nil, nil))) t(x, t(x, t(x, nil, nil), t(x, nil, nil)), t(x, t(x, nil, nil), nil)) ...etc 51. Construct height-balanced binary trees with a given number of nodes. Consider a height-balanced binary tree of height H. What is the maximum number of nodes it can contain? Clearly, MaxN = 2^H - 1. However, what is the minimum number MinN? This question is more difficult. Try to find a recursive statement and turn it into a predicate minNodes/2 defined as follwos: minNodes_p( H ) -> the minimum number of nodes in a height -balanced binary tree of height H. On the other hand, we might ask: what is the maximum height H a height-balanced binary tree with N nodes can have? maxHeight_p( N ) -> the maximum height of a height balanced binary tree with N nodes Now, we can attack the main problem: construct all the height-balanced binary trees with a given number of nodes. hbal_tree_nodes_p( N ) -> height-balanced binary tree with N nodes. Find out how many height-balanced trees exist for N = 15 52. Count the leaves of a binary tree. A leaf is a node with no successors. Example: count_leaves_p( t(a, t(b, t(c, null, null), t(d, null, null)), t(e, null, null)) ) -> 3 The leaf are [ t(c, null, null), t(d, null, null)), t(e, null, null)) ] 53. Collect the leaves of a binary tree in a list A leaf is a node with no successors. Example: leaves_p( t(a, t(b, t(c, null, null), t(d, null, null)), t(e, null, null)) ) -> [ t(c, null, null), t(d, null, null)), t(e, null, null)) ] 54. Collect the internal nodes of a binary tree in a list. An internal node of a binary tree has either one or two non-empty successors. Example: internals_p( t(a, t(b, t(c, null, null), t(d, null, null)), t(e, null, null)) ) -> [ t(a, t(b, t(c, null, null), t(d, null, null)), t(e, null, null)), t(b, t(c, null, null), t(c, null, null)) ] 55. Collect the nodes at a given level in a list. A node of a binary tree is at level N if the path from the root to the node has length N-1. The root node is at level 1. Example: atlevel_p( 2, t(a, t(b, t(c, null, null), t(d, null, null)), t(e, null, null)) ) -> [ t(b, t(c, null, null), t(d, null, null)), t(e, null, null)) ] 56. Construct a complete binary tree. A <i>complete</i> binary tree with height H is defined as follows: The levels 1,2,3,...,H-1 contain the maximum number of nodes (i.e 2**(i-1) at the level i, note that we start counting the levels from 1 at the root). In level H, which may contain less than the maximum possible number of nodes, all the nodes are "left-adjusted". This means that in a levelorder tree traversal all internal nodes come first, the leaves come second, and empty successors (the nil's which are not really nodes!) come last. Particularly, complete binary trees are used as data structures (or addressing schemes) for heaps. We can assign an address number to each node in a complete binary tree by enumerating the nodes in levelorder, starting at the root with number 1. In doing so, we realize that for every node X with address A the following property holds: The address of X's left and right successors are 2*A and 2*A+1, respectively, supposed the successors do exist. This fact can be used to elegantly construct a complete binary tree structure. Write a predicate complete_binary_tree/2 with the following specification: Example: complete_binary_tree_p( 3 ) -> The complete binary tre with N nodes  57. Layout a binary tree. Given a binary tree as the usual Prolog term t(X,L,R) (or nil). As a preparation for drawing the tree, a layout algorithm is required to determine the position of each node in a rectangular grid. Several layout methods are conceivable, one of them is shown in the illustration above. In this layout strategy, the position of a node v is obtained by the following two rules: (1) x(v) is equal to the position of the node v in the inorder (2) y(v) is equal to the depth of the node v in the tree sequence 58. Layout a binary tree (2). Figure located above An alternative layout method is depicted in the above illustration. Find out the rules and write the corresponding solution. Hint: On a given level, the horizontal distance between neighboring nodes is constant. Use the same conventions as in problem 57. 59. Layout a binary tree (3). Figure located above Yet another layout strategy is shown in the above illustration. The method yields a very compact layout while maintaining a certain symmetry in every node. Find out the rules and write the solution. Hint: Consider the horizontal distance between a node and its successor nodes. How tight can you pack together two subtrees to construct the combined binary tree? Use the same conventions as in problem 57 and 58 and test your predicate in an appropriate way. Note: This is a difficult problem. Don't give up too early! Which layout do you like most?  60. A string representation of binary trees Somebody represents binary trees as strings of the following type (see example): a(b(d,e),c(,f(g,))) (a) Write a solution which generates this string representation, if the tree is given as usual (as nil or t(X,L,R) term). Then write a predicate which does this inverse; i.e. given the string representation, construct the tree in the usual form. Finally, combine the two predicates in a single predicate tree_string/2 which can be used in both directions. (b) Write the same predicate tree_string/2 using difference lists and a single predicate tree_dlist/2 which does the conversion between a tree and a difference list in both directions. For simplicity, suppose the information in the nodes is a single letter and there are no spaces in the string. 61. Preorder and inorder sequence of binary trees. We consider binary trees with nodes that are identified by single lower-case letters, as in the example of problem 60. <b></b>(a) Write predicates preorder/2 and inorder/2 that construct the preorder and inorder sequence of a given binary tree, respectively. The results should be atoms, e.g. 'abdecfg' for the preorder sequence of the example in problem 4.16. (b) Can you use preorder/2 from problem part a) in the reverse direction; i.e. given a preorder sequence, construct a corresponding tree? If not, make the necessary arrangements. (c) If both the preorder sequence and the inorder sequence of the nodes of a binary tree are given, then the tree is determined unambiguously. Write a predicate pre_in_tree/3 that does the job. (d) Solve problems (a) to (c) using difference lists. What happens if the same character appears in more than one node. Try for instance pre_in_tree(aba,baa,T). 62. Dotstring representation of binary trees. We consider again binary trees with nodes that are identified by single lower-case letters, as in the example of problem 60. Such a tree can be represented by the preorder sequence of its nodes in which dots (.) are inserted where an empty subtree (null) is encountered during the tree traversal. For example, the tree shown in problem 60 is represented as <tt>'abd..e..c.fg...'</tt>. First, try to establish a syntax (BNF or syntax diagrams) and then write a predicate tree_dotstring/2 which does the conversion in both directions. Use difference lists. Solution: - Haskell
- Lisp
- Prolog
- Python
|
Programming Problem Set: 99 Problems Chapter 3 Posted: 20 Jul 2013 03:10 AM PDT Ninety-nine Problems is generalized version to famous P-99: Ninety-Nine Prolog Problems collection used for teaching programming. The problems initially set for prolog but later many solutions come from various programming language. The purpose of this problem is to give us opportunity to practice our skills in logic programming. The goal is to find the most elegant solution of the given problem. Efficiency is important, but logical clarity is even more crucial. The problem set are divided into seven categories / chapters: Lists, Arithmetic, Logic and Codes, Binary Trees, Multiway Trees, Graphs, and Miscellaneous. In this chapter you will be only given a problem set. The solution might come however it would be on different page. This chapter will cover about Logic and Codes. The problems in this chapter served as continuation of previous problems, therefore the numbering will start from the last problem. 40. Truth tables for logical expression. Define and/2, or/2, nand/2, nor/2, xor/2, impl/2 and equ/2 (for logical equivalence) which succeed or fail according to the result of their respective operations; e.g. and(A,B) will succeed, if and only if both A and B succeed. Now, write a predicate table/3 which prints the truth table of a given logical expression in two variables. Example: table_p( A, B, xor(A,B) ) -> true true false true false true false true true false false false 41. Truth tables for logical expressions (2) Continue problem 40 by defining and/2, or/2, etc as being operators. This allows to write the logical expression in the more natural way, as in the example: A and (A or not B). Define operator precedence as usual; i.e. as in C. Example: table2_p( A, B, A and (A or not B) ) -> true true true true false true false true false false false false 42. Truth tables for logical expression (3). Generalize problem 41 in such a way that the logical expression may contain any number of logical variables. Define table/2 in a way that table(List,Expr) prints the truth table for the expression Expr, which contains the logical variables enumerated in List. The index is started from 1. Example: table3_p( [A,B,C], A and (B or C) equ A and B or A and C) -> <tt>true true true true true true false true true false true true true fail false true false true true true false true false true false false true true false false false true</tt> 43. Gray code. An n-bit Gray code is a sequence of n-bit strings constructed according to certain rules. For example, n = 1: C(1) = ['0','1']. n = 2: C(2) = ['00','01','11','10']. n = 3: C(3) = ['000','001','011','010','110','111','101','100']. Find out the construction rules and write a predicate with the following specification: % gray(N,C) :- C is the N-bit Gray code Can you apply the method of "result caching" in order to make the predicate more efficient, when it is to be used repeatedly? 44. Huffman code. First of all, study a good book on discrete mathematics or algorithms for a detailed description of Huffman codes, or consult wikipedia We suppose a set of symbols with their frequencies, given as a list of fr(S,F) terms. Example: [fr(a,45),fr(b,13),fr(c,12),fr(d,16),fr(e,9),fr(f,5)]. Our objective is to construct a list hc(S,C) terms, where C is the Huffman code word for the symbol S. In our example, the result could be Hs = [hc(a,'0'), hc(b,'101'), hc(c,'100'), hc(d,'111'), hc(e,'1101'), hc(f,'1100')] [hc(a,'01'),...etc.]. Example: huffman_p(Fs,Hs) -> Hs is the Huffman code table for the frequency table Fs Solution: - Haskell
- Lisp
- Prolog
- Python
| Programming Problem Set: 99 Problems Chapter 2 Posted: 20 Jul 2013 02:54 AM PDT Ninety-nine Problems is generalized version to famous P-99: Ninety-Nine Prolog Problems collection used for teaching programming. The problems initially set for prolog but later many solutions come from various programming language. The purpose of this problem is to give us opportunity to practice our skills in logic programming. The goal is to find the most elegant solution of the given problem. Efficiency is important, but logical clarity is even more crucial. The problem set are divided into seven categories / chapters: Lists, Arithmetic, Logic and Codes, Binary Trees, Multiway Trees, Graphs, and Miscellaneous. In this chapter you will be only given a problem set. The solution might come however it would be on different page. This chapter will cover about Arithmetic. A list is either empty or it is composed of a first element (head) and a tail, which is a list itself. As a continuation from previous chapter, the problem will be started from last previous number 29. Determine whether a given integer number is prime. Example: is_prime_p( 7 ) -> Yes 30. Determine the prime factors of a given positive integer. Construct a list containing the prime factors in ascending order Example: prime_factor_p( 315 ) -> [ 3, 3, 5, 7 ] 31. Determine the prime factors of a given positive integer (2) Construct a list containing the prime factors and their multiplicity. Example: prime_factor2_p( 315 ) -> [ [3,2], [5,1], [7,1] ] Hint: The solution of problem 10 may be helpful. 32. A list of prime number Given a range of integers by its lower and upper limit, construct a list of all prime numbers in that range. Example: prime_list_p( 3, 15 ) -> [3, 5, 7, 11, 13 ] 33. Goldbach's conjecture Goldbach's conjecture says that every positive even number greater than 2 is the sum of two prime numbers. Example: 28 = 5 + 23. It is one of the most famous facts in number theory that has not been proved to be correct in the general case. It has been numerically confirmed up to very large numbers. Find the two prime numbers that sum up to a given even integer Example: goldbach_p( 28 ) -> [ 5, 23] 34. A list of Goldbach compositions Given a range of integers by its lower and upper limit, print a list of all even numbers and their Goldbach composition Example: goldbach_list_p( 9, 20 ) 10 = 3 + 7 12 = 5 + 7 14 = 3 + 11 16 = 3 + 13 18 = 5 + 13 20 = 3 + 17 In most case, if an even number is written as the sum of two prime numbers, one of them is very small. Very rarely, the primes are both bigger than say 50. Try to find out how many such cases there are in the range 2..3000. 35. Determine the greatest common divisor of two positive integer numbers Use Euclid's algorithm Example: gcd_p( 36, 63 ) -> 9 36. Determine whether two positive integer numbers are coprime Two numbers are coprime if their greates common divisor equals 1 Example: coprime_p( 35, 64 ) -> Yes 37. Calculate Euler's totient function phi(m) Euler's so-called totient phi(m) is defined as the number of pisitive integers r (1 <= r < m) that are coprime to m. If m = 10 then r = 1, 3, 7, 9; thus phi(m) = 4. Note the special case phi(1) = 1 Example: phi_p( 10 ) -> 4 38. Calculate Euler's totient function phi(m) (2) See the previous problem for definition of Euler's totient function. If the list of the prime factors of a number m is known in the form of problem 32 then the function phi(m) can be efficiently calculated as follows: Let [[p1, m1], [p2, m2], [p3, m3], ...] be the list of prime factors (and their multiplicities) of a given number m. Then phi(m) can be calculated with following formula: phi(m) = (p1-1)* p1^(m1-1) *(p2-1)* p2^(m2-1)*(p3-1)* p3^(m3-1) Note that a^b stands for the b'th power of a. 39. Compare the two methods of calculating Euler's totient function. Use the solution of problem 37 and 38 to compare algorithm. Take the number of logical inferences as a measure for efficiency. Try to calculate phi(10090) as an example Solution: - Haskell
- Lisp
- Prolog
- Python
| The Architecture of PlayStation 1 Posted: 20 Jul 2013 02:20 AM PDT PlayStation, or PlayStation 1 (abbreviate as PS1), is the first generation of home video game console made by Sony Coputer Entertainment. This article will discuss about PlayStation architecture and some important aspects. General Specification PlayStation features ability to read and play audio CDs or Video CDs. The CD player has the ability to shuffle the playback order, play the songs in a programmed order, and repeat one song or the entire disk. PS1 doesn’t have internal storage in which it use external memory card to record data. Memory card is managed by Memory Card Manager which can be accessed by starting the console without inserting a game or keeping the CD tray open. PlayStation 1 support two slot for wired controller and two slot for memory card. The Central Processing Unit Sony PlayStation employ MIPS R3000A compatible 32-bit RISC chip running at 33.8688MHz. The feature of the chip: - Operating performance of 30 MIPS (Million Instructions Per Second)
- Bus bandwidth 132MB/s
- 4kB instruction Cache
- 1kB non-associative SRAM Data Cache
- 2 MB of RAM (integrated)
Geometry transformation engine employed by the CPU give additional vector math instructions used for 3D graphics. The features: - Operating performance of 66 MIPS (Million Instructions Per Second)
- 360,000 polygons per second
- 180.000 texture mapped and light-sourced polygons per second
Inside the CPU also resides MDEC which responsible for decompressing images and video. It reads three RLE (Run Length Encoding) encoded 16×16 macroblocks, run IDCT and assemble a single 16×16 RGB macroblock. The output data may be transferred directly to GPU via DMA (Direct Memory Access). The features: - Compatible with MJPEG and H.261 files
- Operating performance of 80 MIPS (Million Instructions Per Second)
- Directly conneced to CPU Bus
Graphics Processing Unit The GPU handles 2D graphics processing separate from the main 3D engine on CPU. It features: - Maximum of 16.7 million colors (24-bit color depth)
- Resolution from 256×224 to 640×480
- Adjustable frame buffer
- Unlimited color lookup tables
- Emulation of simultaneous backgrounds (for parallax scrolling)
- Flat or Gouraud shading and texture mapping
- 1 MB of VRAM
Sound Processing Unit The SPU supports ADPCM (Adaptive Differential Pulse-code Modulation) sources with up to 24 channels. The sampling rate of up to 44.1 kHz and having 512 kB of memory. CD ROM The drive is a tray with XA Mode 2 Compliant. It use CD-DA (CD-Digital Audio) and use 128 kB buffer with maximum data throughput reach 300 kB/s Connectivity PlayStation has AV Multi Out. As PlayStation has numerous variants during its production, the hardware configuration especially connectivity might vary. For SCPH-100x to SCPH-3xxx, PlayStation has RCA Composite video and Stereo out. It also has RFU DC Out. The older SCPH-1000 has S-Video out. | Assembly Primer for Hackers – Video Tutorial Posted: 19 Jul 2013 08:35 PM PDT Programming in Assembly is not as easy as higher level language. The main factor is because you can’t find syntax such as if, while, etc. However one of our kind heart friend from SecurityTube has made us a very interesting video for learning Assembly. Here the list of video. Please bear in mind that I don’t made these and I have no claim over it. As stated in other page, this site and NEST is originally serve a purpose as personal documentation. These videos are actually good starter for anyone who want to dive deeper in computer field, especially who have interest in cracking, exploitation, etc. The tutorials consists of eleven modules. Module 1 – System Organization Assembly language is probably the most important thing one needs to master if he desires to enter the world of code exploitation, virus writing and reverse engineering. In this multi-part video series I will try to provide a simple primer to Assembly language which will help you get started. These videos are in no way meant to be exhaustive but rather will only act as a guide on how to begin. <br><br>In this first part, I explain the basics of computer organization, CPU registers – general purpose, segment and instruction pointer. Also covered is virtual memory organization, program memory organization, program stack and stack operations. Download: EmbedUpload | MirrorCreator Module 2 – Virtual Memory Organization In this video we take an in-depth look at virtual memory organization concepts. The entire discussion is explained by taking a live example using the SimpleDemo.c code. We look at how one can use the /proc/PID/maps to peek into the layout of a program’s virtual memory and interpret useful things. Also, we show how the Address Space Layout Randomization (ASLR) works in the latest 2.6 kernels and why this is significant from a security point of view. We also show how this can be disabled at runtime if the need be. This video is very important from an code exploitation perspective as it teaches us how to check for the presence of ASLR on a given system. Download: EmbedUpload | MirrorCreator Module 3 – Gdb Usage GDB (GNU Debugger) is probably one of the most important tools one needs to be familiar with in order to be a good assembly language programmer. In this video we go through a quick primer on how to use GDB to disassemble code, set breakpoints, trace through code, examine CPU registers and memory locations, examine the program stack and many other important use cases which will help us in later videos when we actually start coding in Assembly and want to debug our code. Download: EmbedUpload | MirrorCreator File for this Module: SimpleDemo.c Module 4 – Hello World In this video we will look at the structure of assembly language programs – .data, .bss, .text segments, how to pass arguments to linux system calls in assembly, using GAS and LD to assemble and link code and finally in the end we go through a step by step approach to create our first “Hello World” program. Download: EmbedUpload | MirrorCreator File for this Module: JustExit.s | HelloWorldProgram.s Module 5 – Data Types In this video we will go through an in-depth primer on data types which are used in assembly. We do a live demo on how to look at data in memory using GDB for .ascii, .int, .short, .float (.data) and .comm, .lcomm (.bss) types. Download: EmbedUpload | MirrorCreator File for this Module: VariableDemo.s Module 6 – Moving Data In this video we look at how to transfer data between registers and memory locations using the MOV series of instructions. We discuss data transfer between registers, immediate values and registers, memory locations and registers, immediate values and memory locations, indexed memory addressing schemes, indirect addressing using registers and many other important concepts. It is important to note that all the above are explained in detail using example code in the video. Download: EmbedUpload | MirrorCreator File for this Module: MovDemo.s Module 7 – Working with Strings In this video we will look at how to work with strings in Assembly. We will demonstrate how we can move strings from one memory location to the other using the MOVS instruction set, discuss the concept of the Direction Flag (DF) and how to set and clear it using STD and CLD, how to execute multiple string copy instructions using the REP instruction, how to load strings from memory into the EAX register using the LODS instruction set, how to store strings from the EAX register back into memory using the STOS instruction set and finally we shall look at how to compare strings using the CMPS instruction set. Download: EmbedUpload | MirrorCreator Module 8 – Unconditional Branching In this video we will look at how to alter the program execution flow using unconditional branching. We will look at how to use the JMP instruction to make an unconditional branching to a new location in the code segment and how to use the CALL statement in conjunction with RET to save the program execution state. We will demonstrate all the concepts using very simple code snippets to aid understanding. Download: EmbedUpload | MirrorCreator File for this Module: UnconditionalBranching.s Module 9 – Conditional Branching In this video we will look at Conditional Branching in Assembly Language using the JXX family of instructions and the LOOP instruction. The conditional jump instructions such as JA, JAE, JZ, JNZ etc. use various flags in the EFLAGS register such as the Zero Flag (ZF), the Parity Flag (PF), Overflow Flag (OF), Sign Flag (SF) etc. to determine which instruction path to take next. In this video we will look at the JZ condition jump instruction in great detail. JZ using the Zero Flag (ZF) to determine if the last instruction resulted in the Zero operation or not and then chooses to jump to a specified location if it was set. We will also look at the LOOP instruction which used the ECX register to loop over a set of instructions over and over again. Download: EmbedUpload | MirrorCreator File for this Module: ConditionalBranching.s Module 10 – Functions In this video we will look at how to write functions in Assembly Language. <br><br>The most important step in writing functions in assembly is to understand how to pass arguments to them and then read their return values. We will look at 2 techniques – using registers and using global memory locations to understand how this can be done. In this demo we will use our familiar “Hello World” program to demonstrate how to code a simple function using the “write()” syscall. We will use the Function.s program to demonstrate argument passing using the CPU registers and Function2.s to demo argument passing using global memory location in the .BSS segment. Download: EmbedUpload | MirrorCreator File for this Module: Function.s | Function2.s Module 11 – Functions Stack In this video, we will look at how to use the Stack to pass arguments to functions. <br><br>In course of this video we will look into exactly how the Stack works, how to store arguments on the stack, how the “call” instruction stores the return address on the stack, the logic behind storing the EBP register on the stack, how and why EBP is used to reference function arguments and local variables in a function and how to adjust the ESP to accommodate all this. This video is very important as a lot of learning from this will be used in the Buffer overflow video series I plan to make next. Download: EmbedUpload | MirrorCreator File for this Module: Function3.s | Nmap Video Tutorials and Trainings Posted: 19 Jul 2013 06:14 PM PDT Nmap or Network Mapper is the tools to conduct a networking mapping. Using Nmap, one can know whether computer or host active and obtain further information about the target. Nmap is available in a variety of operating system such as Linux and Windows. The video tutorials on this page is made by Professor Messer. If you value this product, you can consider purchase this from www.professormesser.com/professor-messers-nmap-secrets-training-course/. These video is password protected and archived with 7zip. Once you download it, rename the extension from .xar to .7z and extract it. As the archive is password protected, to be able to extract the file you should enter the correct password. The password is: xathrya.web.id. If you want to share this, please only share this page URL or link listed here. The tutorials consists of eleven modules. These modules require a web browser with working adobe flash installed. Please make sure your browser support it. Module 1 – Getting Started with Nmap Overview of the entire course, along with a sneak peek of the secrets that will be uncovered along the way. Download: EmbedUpload | MirrorCreator Module 2 – Nmap Basics Overview of network protocols, the Nmap scan process, and secrets for increasing the speed of this process. Download: EmbedUpload | MirrorCreator Module 3 – Scans for Every Occasion Introduces four of the most popular, most useful, and most versatile Nmap scanning methods: TCP SYN scan, TCP connect() scan, Ping scan, and UDP scan. Download: EmbedUpload | MirrorCreator Module 4 – “Back Pocket” Scans Sometimes, you'll run into a situation where a normal Nmap scan isn't providing you with all of the information you need. This may be a situation where remote devices aren't responding, or perhaps you aren't able to identify any available ports on a remote device – even though you can easily connect to its web server! In these situations, it's useful to have a few tricks in your back pocket. Download: EmbedUpload | MirrorCreator Module 5 – Useful Scanning Options Concentrate on some useful scanning options that will assist in building Nmap scan sessions that are effective and efficient. Download: EmbedUpload | MirrorCreator Module 6 – Nmap “Pings” : The Search for Hosts There's a lot to Nmap's ping process, and we'll start with defining a ping. From there, we'll move to Nmap's default pings – the ARP ping and the ICMP and TCP ACK ping combo. To really make the most of Nmap's pings, we'll also investigate the details of the TCP SYN ping and the UDP ping. Download: EmbedUpload | MirrorCreator Module 7 – Recon Scanning Investigae the secrets of network reconnaissance and take the details of two major Nmap features – operating system fingerprinting and version detection. Download: EmbedUpload | MirrorCreator Module 8 – Ninja Scanning Introduce to Nmap’s art of invisibility. Learn the secrets of using Nmap on network in stealth mode, where you can go come and go like the wind. Download: EmbedUpload | MirrorCreator Module 9 – Output Options Nmap includes a number of output options, and this module takes us through them all. We'll show you the differences in the output options, including how to convert Nmap's XML output into some great HTML-based reports. Download: EmbedUpload | MirrorCreator Module 10 – Windows Nmap Learn about the history of Nmap and Windows – both the good, and the bad. Although there have been some significant operational issues with Windows-related issues that exist today are easy to work around. Download: EmbedUpload | MirrorCreator Module 11 – Real-World Nmap Scanning Discuss six Nmap scanning techniques that can get you through some pretty nasty security problems. Download: EmbedUpload | MirrorCreator |
Programming Problem Set: 99 Problems Chapter 1 Posted: 12 Jul 2013 08:57 AM PDT Ninety-nine Problems is generalized version to famous P-99: Ninety-Nine Prolog Problems collection used for teaching programming. The problems initially set for prolog but later many solutions come from various programming language. The purpose of this problem is to give us opportunity to practice our skills in logic programming. The goal is to find the most elegant solution of the given problem. Efficiency is important, but logical clarity is even more crucial. The problem set are divided into seven categories / chapters: Lists, Arithmetic, Logic and Codes, Binary Trees, Multiway Trees, Graphs, and Miscellaneous. In this chapter you will be only given a problem set. The solution might come however it would be on different page. This chapter will cover about Lists. A list is either empty or it is composed of a first element (head) and a tail, which is a list itself. 01. Find the last element of a list. Example: last_p( [a, b, c, d] ) -> d 02. Find the last but one element of a list. Example: last_one_p( [a, b, c, d] ) -> c 03. Find the n'th element of a list. The index is started from 1. Example: at_p( [a, b, c, d], 3) -> c 04. Find the number of elements of a list. Example: length_p( [a, b, c, d] ) -> 4 05. Reverse a list. Example: reverse_p( [a, b, c, d] ) -> [d, c, b, a] 06. Find out whether a list is a palindrome. A palindrome ca be read forward of backward. Example: palindrom_p( [a, b, c, b, a] ) -> true 07. Flatten a nested list structure. Transform a lists as elements into a 'flat' list by replacing each list with its element (recursively) Example: flatten_p( [a, [b, 1, e]] ) -> [a, b, c, d, e] 08. Eliminate consecutive duplicates of list elements. If a list contains repeated elements they should be replaced with a single copy of the element. The order of elements should not be changed. Example: compress_p( [a, a, a, a, b, c, c, a, a, d, e, e, e, e] ) -> [a, b, c, a, d, e] 09. Pack consecutive duplicates of list elements into sublists. If a list contains repeated elements, they should be placed in separate sublist. Example: pack_p( [a, a, a, a, b, c, c, a, a, d, e, e, e, e]) -> [ [a, a, a, a], [b], 1, [a, a], [d], [e, e, e, e,] ] 10. Run-length encoding of a list. Consecutive duplicates of elements are encoded as terms [N, E] where N is the number of duplicates of the element E. Example: encode_p1( [a, a, a, a, b, c, c, a, a, d, e, e, e, e] ) -> [ [4,a], [1,b], [2,c], [2,a], [1,d], [4,e]] 11. Modified run-length encoding. Consecutive duplicates of elements are encoded as terms [N, E] where N is the number of duplicates of the element E. If an element has no duplicates, it is simply copied into the result list Only duplicates are transferred as [N, E] terms. Example: encode_p2( [a, a, a, a, b, c, c, a, a, d, e, e, e, e] ) -> [ [4,a], b, [2,c], [2,a], d, [4,e] ] 12. Decode a run-length encoding list.. Given a run-length code list generated, construct its uncompressed version. Example: encode_p3( [4,a], [1,b], [2,c], [2,a], [1,d], [4,e]) -> [a, a, a, a, b, c, c, a, a, d, e, e, e, e] ] 13. Run-length encoding of a list (direct solution). Implement the so-called run-length encoding data compression method directly. Don't explicitly create the sublists containing the duplicates but only count them. Simplify the result list by replacing the singleton terms [1,X] by X. Example: encode_p4([a, a, a, a, b, c, c, a, a, d, e, e, e, e]) -> [ [4,a], b, [2,c], [2,a], d, [4,e]] 14. Duplicate the elements of a list. Example: duplicate_p([a, b, c, d, e]) -> [a, a, b, b, c, c, d, d, e, e] 15. Duplicate the elements of a list a given number of times. Example: duplicate_px([a, b, c, d, e], 3) -> [a, a, a, b, b, b], c, c, c, d, d, d, e, e, e] 16. Drop everh N'th element from a list. Example: drop_p([a, b, c, d, e, f, g, h, i, k], 3) -> [a, b, d, e, g, h, k] 17. Split a list into two parts; the length of the first part is given. Do not use any predefined predicates / function. Example: split_p([a, b, c, d, e, f, g, h, i, k], 3, L1, L2) -> L1 = [a, b, c] ; L2 = [d, e, f, g, h, i, k] 18. Extract a slice from a list. Given two indices, I and K, the slice is the list containing the elements between the I'th and K'th element of the original list (both limits included). Start counting the element with 1. Example: slice_p([a, b, c, d, e, f, g, h, i, k], 3, 7) -> 1 19. Rotate a list N places to the left. Example: rotate_p([a, b, c, d, e, f, g, h], 3) -> [d, e, f, g, h, a, b, c] rotate_p([a, b, c, d, e, f, g, h],-2) -> [g, h, a, b, c, d, e, f] 20. Remove the K'th element from a list. Example: remove_p([a, b, c, d], 2) -> [a, c, d] 21. Insert an element at a given position into a list. Example: insert_p(x, [a, b, c, d], 2) -> [a, x, b, c, d] 22. Create a list containing all integers withing a given range. Example: range_p(4, 9) -> [4, 5, 6, 7, 8, 9] 23. Extract a given number of randomly selected elements from a list. The selected items shall be put into a result list. Example: rnd_select_p1([a, b, c, d, e, f, g, h], 3) -> [g, a, c] 24. Draw N different random numbers from the set 1..M. The selected numbers shall be put into a result list. Example: rnd_select_p2(6, 49) -> [23, 1, 33, 21, 37, 17] 25. Generate a random permutation of the elemnts of a list. Example: rnd_permut_p([a, b, c, d, e]) -> [b, a, d, c, e, f] 26. Generate the combinations of K distinct objects chosen from the N elements of a list. In how many ways can a committee of 3 be chosen from a group of 12 people? There are C(12,3) = 220 possibilities denotes the well-known binomial coefficients. Example: combination_p([a, b, c, d, e, f]) [a, b, c] [a, b, d] [a, b, e] ... 27. Group the elements of a set into disjoint subsets. (a) In how many ways can a group of 9 people work in 3 disjoint subgroups of 2, 3, and 4 persons? Example: group3_p([aldo,beat, carla, david, evi, flip, gary, hugo, ida]) G1 = [aldo, beat], G2 = [carla, david, evi], G3 = [flip, gary, hugo, ida] (b) Generalize the above function in a way that we can specify a list of group sizes and the predicate will return a list of groups Example: group_p([aldo, beat, arla, david, evi, flip, gary, hugo, ida],[2, 2, 5]) -> [[aldo,beat],[carla,david],[evi,flip,gary,hugo, ida]] 28. Sorting a list of lists according to length of sublists. (a) Suppose that a list (InList) contains elements that are lists themselves. The objective is to sort the elements of InList according to their length. E.g. short lists first, longer lists later, or vice versa. Example: lsort_p([[a, b, c], [d,e],[f,g,h], [d,e], [i,j,k,l], [m,n],[o]]) -> [[o],[d, e],[d, e],[m, n],[a, b, c],[f, g, h],[i, j, k, l]] (b) Suppose a list (InList) contains elements that are list themselves. But this time the objective is to sort the elements of InList according to their length frequency. i.e. in the default, where sorting is done ascendingly, lists with rare lengths are placed first, others with a more frequent length come later. Example: lfsort_p([[a, b, c], [d,e],[f,g,h], [d,e], [i,j,k,l], [m,n],[o]]) -> [[i, j, k, l],[o],[a, b, c],[f, g, h],[d, e],[d, e],[m, n]] Not that in the above example, the first two list in the result have length 4 and 1, both lengths appear just one. The third and forth list have length 3, there are two list of this length. And finally the last three lists have length 2. This is the most frequent length | Login as Root in Ubuntu 13.04 Posted: 12 Jul 2013 03:54 AM PDT Do you want to enable root logon in Ubuntu 13.04? Root account is an account who has power over the system. Login as root / administrator account is not recommended, because people make mistakes. It’s easier to exploit human than machine. Making smallest mistakes while logging in as root can completely render your computer useless (or at least inoperable). Even though it’s not recommended, it’s still possible to logon as root on Ubuntu. This article will discuss about how to enable root login on Ubuntu 13.04. To enable root account, press CTRL + ALT + T or open terminal and run following command: sudo passwd root That command will set password for root account. You should enter new password twice (the last one for confirmation). After that, you need to configure DM (Desktop Manager) to allow login as root account in the Login Screen. By default, Ubuntu 13.04 use LightDM. To configure, edit /etc/lightdm/lightdm.conf and add following line: greeter-show-manual-login=true Or you can invoke this at command line (make sure you type correctly): echo 'greeter-show-manual-login=true' >> /etc/lightdm/lightdm.conf Next time you login, you should enter the account name and its password. To disable root account, run this command: sudo passwd -l root |
Installing Bit-Defender Anti Virus on Ubuntu Posted: 11 Jul 2013 03:37 AM PDT “Is Linux immune to viruses?” This kind of questions might come from linux new comers or someone that begin interest in Linux. Sadly, the answer is no. Specifically, there are virus for every Operating System, even Linux can be infected (refer to Wikipedia). However, if you said if Linux is immune to Windows’ viruses, then the answer might be yes. As viruses mainly “developed” for windows Operating System, they won’t be less effective or even can’t infect Linux. One of the reason is the two operating system has different system and layout. So what the point of this article? Even though Linux won’t be affected by Windows’ viruses, there are many reason why we should install an AV (Anti Virus). For some reason we might explain: - We might transfer (send / receive) file with virus. It might be bad if we send a virus accidentally.
- Scan viruses on Windows file system. We can use Linux to scan our partition used by Windows.
- etc
One of Anti Virus choice out there is Bit Defender. In this article, we will discuss about installing Bit-Defender Anti Virus for Ubuntu. For this case, I use Ubuntu 12.10 as working example. Preparation The package is not provided by Ubuntu repository. To install BitDefender, we must install it from their repository. Before we do that, we should Bit Defender repository to our list. wget -O- -q http://download.bitdefender.com/repos/deb/bd.key.asc | sudo apt-key add - sudo sh -c 'echo "deb http://download.bitdefender.com/repos/deb/ bitdefender non-free" >> /etc/apt/sources.list' sudo apt-get update Installation Installation is quick like installing other Ubuntu package. Do following command: sudo apt-get install bitdefender-scanner-gui At this point, you should find Bit Defender installed |
Install Kernel on Ubuntu Posted: 11 Jul 2013 03:10 AM PDT One advantage of using Linux is you can change your kernel when the latest one out. For Ubuntu, you can have a painless way to install a new kernel. In this article, we will discuss about generic (and painless) way to install new kernel. For this case, I use Ubuntu 12.10 and the kernel we will install is 3.10 version. How to Check Kernel Version? To check your current linux kernel version, enter this command on terminal: uname -r or cat /proc/version Ubuntu and Precompiled Kernel Unlike compiling kernel by yourself, Ubuntu provide you with precompiled kernel. It means, they compile the kernel for you. It might good for anyone who want to install new kernel effortlessly. However, the drawback for this precompiled kernel is the kernel is optimized for general machine. It want to address all the hardware and machine condition resulting in bigger size. Yes it can run on any machine, but might not be optimized. If you want to optimized the kernel for your machine in specific way, you might want to consider compiling kernel from source. Obtain the Material First, grab the material, the kernel. Go to this link, and find your preferred kernel. For example, I will use kernel labelled by v3.10-saucy. Note that the Ubuntu release two kind of package: linux image and linux headers. The kernel itself is packaged as linux image. The linux headers are collection of headers file used for compile third party driver. Or in generic way: it is header file of linux. For each kind, there are two package namely package for 32 bit and for 64 bit architecture. Download the kernel suitable for your Ubuntu, i.e if you use 32 bit ubuntu then choose the i686 version. Otherwise, download the amd64 version. For v3.10-saucy, we have following options: [32 bit] - Linux Image
- Linux Headers
[64 bit] - Linux Image
- Linux Headers
The rest of this article will use Kernel to refer Linux Kernel / Image you have downloaded (.deb format) while the Headers will refer to Linux Headers. Installation Put both Kernel and Headers into the same location. Open terminal and navigate to that directory. To install, use following commands (with root privilege): dpkg -i *.deb Next, reboot the system reboot And check the version: uname -a It should give you version 3.10 |
Upgrade Debian from 6 (Squeeze) to 7 (Wheezy) Posted: 09 Jul 2013 06:54 PM PDT Debian always has at least three releases in active maintenance: stable , testing and unstable . - stable
- The
stable distribution contains the latest officially released distribution of Debian. This is the production release. - testing
- The
testing distribution contains packages that haven’t been accepted into a stable release yet, but they are in the queue for that. The main advantage of using this distribution is that it has more recent versions of software. - unstable
- The
unstable distribution is where active development of Debian occurs. Generally, this distribution is run by developers and those who like to live on the edge. With new stable Debian release, Debian Wheezy, many new features introduced. To use Debian Wheezy, one can download and install the fresh Debian Wheezy, or upgrade the the previous one to the latest. In this article, we will discuss about how to upgrade Debian Squeeze (version 6) to Debian Wheezy (version 7). The process will be carried on Virtual Machine, with following situation on: - Slackware64 14.0 as host
- VirtualBox 4.2.16
- Debian Squeeze amd64
This method is generic therefore, you can also do this to actual production machine. It is also should be applied to x86 machine (32 bit). For upgrade, you should have internet connection. This will be needed to download the update, though we can also use local repository but this is not recommended. For the rest of article, I assume you use root privileges to execute command. Preparation Always do a backup! It is important to make a backup of your system before you do this. The official Debian document recommends: “The main things you’ll want to back up are the contents of /etc, /var/lib/dpkg, /var/lib/apt/extended_states and the output of dpkg –get-selections “*” (the quotes are important). If you use aptitude to manage packages on your system, you will also want to back up /var/lib/aptitude/pkgstates. The upgrade process itself does not modify anything in the /home directory. However, some applications (e.g. parts of the Mozilla suite, and the GNOME and KDE desktop environments) are known to overwrite existing user settings with new defaults when a new version of the application is first started by a user. As a precaution, you may want to make a backup of the hidden files and directories ("dotfiles") in users’ home directories. This backup may help to restore or recreate the old settings. You may also want to inform users about this.” Stage 1 First we need to edit our repository and point it to Wheezy repository. Edit /etc/apt/sources.list. You can do it using any editor. Find words squeeze and replace it with wheezy. It is also recommended that you use nearest mirror repository (for example: http://kambing.ui.ac.id for Indonesia). If you have done editing it, update it by using: apt-get update This will update the index and package list and point them to wheezy. Stage 2 Next, upgrade the packages. We need this before upgrade our debian. apt-get upgrade Stage 3 Next, we upgrade the distribution itself. apt-get dist-upgrade After the upgrade, reboot the system. reboot Verify your system by invoking following command: lsb-release -a It should give you something like this: No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 7.0 (wheezy) Release: 7.0 Codename: wheezy You should check the kernel version also. To do that, enter: uname -mrs Which should give you following output: Linux 3.2.0-4-amd64 x86_64 Check for erros on log files: tail -f /var/log/messages egrep -i --color 'err|warn|crit' /var/log/fileName At this point, our Debian has been upgrade to Wheezy.
|
|